Perl-Sensitive Sunglasses | |
PerlMonks |
Re: Re: Sorting characters within a stringby dga (Hermit) |
on Aug 24, 2001 at 23:42 UTC ( [id://107676]=note: print w/replies, xml ) | Need Help?? |
Nice Idea to precompute the values. I got 3901 which represents the entire set of 2-4 letter long unsorted inputs in this alphabet. This of course folds to a very small number of sorted outcomes. Here is the code.
This creates a complete list of inputs you could obtain and builds a hash with the outputs you want to display. It does this fairly quickly and would only have to be done at startup time and then your print statement would bacically be print "$pp{$_}\n"; This could be made into an initializer function or the values could be computed and saved out and then read in for execution of the real program.
In Section
Seekers of Perl Wisdom
|
|