There's more than one way to do things | |
PerlMonks |
Re: literati cheat / finding words from scrambled lettersby gryphon (Abbot) |
on Nov 20, 2005 at 22:50 UTC ( [id://510305]=note: print w/replies, xml ) | Need Help?? |
Greetings sulfericacid, After only a brief bit of thought, two options come to mind: the "top down" and "bottom up" methods (thus named because I can't think of a better name right now). The "top down" approached would be to write a script that:
That may not be the fastest script to run, but it would work, and it would be fairly easy to code and very easy to setup (just a single script and a dictionary file). However, the "bottom up" approach would probably be faster to run. In this approach, you do all the work up front:
The second option would be more difficult to implement, and it would require some setup time to run, but the "production" version would be faster (I'm guessing) than the "top down" method for two reasons: During a run, the first option has to create and search against every possible combination of letters. For larger inputs (those approaching 7), this could be slow. The second option only has to sort the input and lookup the value; thus it's very fast. I hope this helps out. gryphon
In Section
Seekers of Perl Wisdom
|
|