games-request@tekred.TEK.COM (07/16/87)
Submitted by: Nick Flor <nick@hp-sdd.HP.COM> 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 <file", e.g.. If this archive is complete, you # will see the following message at the end: # "End of shell archive." # Contents: README Makefile jumble.c guess.sh # Wrapped by billr@tekred on Thu Jul 16 09:28:40 1987 PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test -f README -a "${1}" != "-c" ; then echo shar: Will not over-write existing file \"README\" else echo shar: Extracting \"README\" \(218 characters\) sed "s/^X//" >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 <README`; then echo shar: \"README\" unpacked with wrong size! fi # end of overwriting check fi if test -f Makefile -a "${1}" != "-c" ; then echo shar: Will not over-write existing file \"Makefile\" else echo shar: Extracting \"Makefile\" \(85 characters\) sed "s/^X//" >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 <Makefile`; then echo shar: \"Makefile\" unpacked with wrong size! fi # end of overwriting check fi if test -f jumble.c -a "${1}" != "-c" ; then echo shar: Will not over-write existing file \"jumble.c\" else echo shar: Extracting \"jumble.c\" \(1127 characters\) sed "s/^X//" >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 <word>"); X exit(0); X } X bigword = argv[1]; X jumble(argv[1]); X} END_OF_jumble.c if test 1127 -ne `wc -c <jumble.c`; then echo shar: \"jumble.c\" unpacked with wrong size! fi # end of overwriting check fi if test -f guess.sh -a "${1}" != "-c" ; then echo shar: Will not over-write existing file \"guess.sh\" else echo shar: Extracting \"guess.sh\" \(294 characters\) sed "s/^X//" >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 <guess.sh`; then echo shar: \"guess.sh\" unpacked with wrong size! fi chmod +x guess.sh # end of overwriting check fi echo shar: End of shell aechye the dng l