in reply to regex for word puzzle

If you really wanted to use regex, you can use it to narrow the dictionary list before preformming one of the above (most notably Zaxo's) methods.
my $jumble = 'RTESAMCNA'; open FILE, "/usr/share/dict/words"; my $n = length $jumble; my @possible_words = grep /^[$jumble]{$n}$/i, map {chomp; $_} <FILE> +; close FILE;
This narrows (with the dictionary i have) the list for "RTESAMCNA" down to just 35 words. From there, you can use the lc/split/sort/join & hash method to get the final list (for example, it finds 'treatment', but clearly that should be excluded). Obvisouly the longer the jumble, the better off this initial pass is.. (And depends on the letter combinations, too)

Replies are listed 'Best First'.
Re^2: regex for word puzzle
by inman (Curate) on Jun 13, 2005 at 12:14 UTC
    The hash isn't necessary unless you are trying to match multiple words. Just test each word that matches the pattern. This also has the advantage of handling multiple possible anagrams that could exist in the word file. e.g. meat->team->meta->mate. You could also add a simple string length check as the first filter.