Every Word is a fun word scramble game. Although it is fun, from time to time I cannot help thinking how easily it can be beat by cheating. Eventually, giving up to the temptation, I write a program help me crack the game.

In each round, the game provides you a bag of letters (typically 5~7). Your mission is to find out all the English words consisting of a subset of the provided letters.

everyword.py :  a program that generates all substrings whose length is no smaller than 3 of the input string

And following is a list of file required for creating an anagram dictionary.
(There is a nice example of anagram program in the book "programming pearls".)
sign.py:      creates a unique signature for each word. The signature is to sort the letters of the word in the alphabetical order in this case.
squash.py: outputs an anagram dictionary
dictionary: a English dictionary in which each word occupies a single line

Finally, a script finishes the remaing work: find all the sub-words in a ascending order of the word length

for word in `python everyword.py input`;do cat anagram.txt | grep -w $word | awk '{for(i=2;i<=NF;i++)print $i}'; done | awk '{print length, $0}' | sort -n | awk '{$1="";print $0}'

Run the above command, the terminal outputs:
 nip
 nit
 nut
 pin
 pit
 pun
 put
 tin
 tip
 tui
 tup
 pint
 punt
 tupi
 unit
 input
 punti