Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: regex for word puzzle

by davidrw (Prior)
on Jun 13, 2005 at 02:27 UTC ( [id://466035]=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://466035]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2024-04-25 11:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found