perl_wizard2 has asked for the wisdom of the Perl Monks concerning the following question:
Once you know the letters that are needed for the last word, is there a good perl program to show you all the combinations of dictionary words that are possible?
I did the code below, but I've got to wonder, is there a better way?
cat linux.words | perl -e 'while(<>) {if(/^[rgtnaie][rgtnaie][rgtnaie] +[rgtnaie][rgtnaie][rgtnaie][rgtnaie][rgtnaie][rgtnaie]$/) { %letters += (); chomp; $word = $_; while($letter = chop) {$letters{$letter}++;} + if(($letters{'e'} == 2) && ($letters{'t'} == 2) && ($letters{'i'} == + 1) && ($letters{'n'} == 1) && ($letters{'g'} == 1) && ($letters{'r'} + == 1) && ($letters{'a'} == 1)) {print "FOUND: $word\n"; }}}'
The code above would find all words that have 2 e's, 2 t's, and one each of i, n, g, r and a. The one I found was 'integrate'.
TIA,
Jason
Edit Masem 2001-08-06 - Title appended with "for finding anagrams"
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Is there a better way?
by tachyon (Chancellor) on Aug 04, 2001 at 00:39 UTC | |
by dragonchild (Archbishop) on Aug 04, 2001 at 00:49 UTC | |
by tachyon (Chancellor) on Aug 04, 2001 at 00:56 UTC | |
Re: Is there a better way?
by dragonchild (Archbishop) on Aug 04, 2001 at 00:45 UTC | |
Re: Is there a better way?
by chipmunk (Parson) on Aug 04, 2001 at 00:57 UTC | |
Re: Is there a better way?
by runrig (Abbot) on Aug 04, 2001 at 03:25 UTC |