Word Problem |
In a popular puzzle often found in newspapers, a set of letters is provided, and the challenge is to find how many different words can be made from these letters. This problem is designed to take all the fun out of it by automating the process.
After the dictionary there will be data for several word puzzles, each on a separate line. Each puzzle
line will have from one to 7 lower case letters, separated by one or more spaces. Your task is to arrange
some or all of these letters to form words in the dictionary. The list of puzzles will be terminated by a
line consisting of a single `#'.
Note that each letter may be used only as many times as it appears in the puzzle line. For instance,
the puzzle line `u l l' may produce the word `lul' but not the word `lull'.
ant bee cat dog ewe fly gnu # b e w b b e e w w t a n c u g d #
0 2 3