go ahead... be a heretic | |
PerlMonks |
Re: Challenge: Mystery Word Puzzleby tall_man (Parson) |
on Jan 14, 2005 at 01:27 UTC ( [id://422142]=note: print w/replies, xml ) | Need Help?? |
It seems to me that great efficiencies could be had by applying logical reductions to the rules first. For example, in your given problem, take all the letters for "0 letters" out first:
In this case, one rule has reduced to a perfect match. The mystery word must contain 'o','l', and 'r'. I then could subtract those letters from the remaining rules, reducing the counts accordingly. Now the word has one letter in common with 'hs'. Now I can search for /^[rolh]{5}$/ and /^[rols]{5}$/, finding 'rolls' and 'solos'. (Update: Of course 'solos' must be eliminated, leaving 'rolls' as the only solution.) I believe this method could be generalized to a solution-space searching recursive algorithm. I will try to write it up when I have time.
In Section
Seekers of Perl Wisdom
|
|