Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!lll-lcc!ames!ucbcad!ucbvax!decvax!tektronix!tekgen!tekred!games-request From: games-request@tekred.TEK.COM Newsgroups: comp.sources.games Subject: v01i096: jumble - de-jumble those infernal word puzzles Message-ID: <1406@tekred.TEK.COM> Date: Thu, 16-Jul-87 12:32:49 EDT Article-I.D.: tekred.1406 Posted: Thu Jul 16 12:32:49 1987 Date-Received: Sat, 18-Jul-87 13:28:03 EDT Sender: billr@tekred.TEK.COM Lines: 144 Approved: billr@tekred.TEK.COM Submitted by: Nick Flor Comp.sources.games: Volume 1, Issue 96 Archive-name: jumble [The package as I received it contained just the C source file. I added a simple Makefile and the "guess" shell script. Maybe now I'll start playing those word games in the paper :-) -br] #! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh README <<'END_OF_README' Xjumble: A jumble (TM) de-jumbler. The ultimate weapon to use Xagainst the Jumble (tm) puzzle. This program helps solve the Xpuzzle by listing all permutations of letters is a given word. X X Nick Flor X hp-sdd!nick END_OF_README if test 218 -ne `wc -c Makefile <<'END_OF_Makefile' X# Makefile for jumble XCFLAGS = -O X Xjumble: jumble.c X cc $(CFLAGS) -o jumble jumble.c END_OF_Makefile if test 85 -ne `wc -c jumble.c <<'END_OF_jumble.c' X/* X * jumble.c: X * A jumble (TM) de-jumbler. X * The ultimate weapon to use against the Jumble (tm) puzzle. X * X * Copyright (C) 1987, Nick V. Flor X * X * Permission is granted to freely distribute this source. X * Unless you try to make money off of it. (Not bloody likely) X * X * If you really enjoy this program, please send me Disneyland money. X * (Or e-mail me a better version) X * X */ Xstatic char X *bigword; X X#define swap(a, b, t) t = a; a = b; b = t; X/* X * jumble: X * Solve those darn jumble thingamajiggies in the San Diego Union X * and other newspapers across the world. X * X * entry: X * word -- The word to be jumbled. X * X */ Xjumble(word) Xchar X *word; X{ Xint X i = 0; Xchar X ch; X X if (!*word) /* Printing at the end of the recursion */ X printf("%s\n", bigword);/* is sufficient */ X else while (word[i]) { X swap(word[0], word[i], ch); X jumble(&word[1]); X swap(word[0], word[i], ch); X i++; X } X} X X Xmain(argc, argv) Xint X argc; Xchar X *argv[]; X{ X if (argc != 2) { X puts("usage: jumble "); X exit(0); X } X bigword = argv[1]; X jumble(argv[1]); X} END_OF_jumble.c if test 1127 -ne `wc -c guess.sh <<'END_OF_guess.sh' X#! /bin/sh X# shell script to make a reasonable first guess at a likely de-jumbled X# word. The jumble program generates all permutations; this script X# only prints ones that are in the dictionary. X# Bill Randle (billr@tekred.TEK.COM) X# XDict=/usr/dict/words Xjumble $1 | sort | comm -12 - $Dict END_OF_guess.sh if test 294 -ne `wc -c