|
|
| go ahead... be a heretic | |
| PerlMonks |
Re: How can I improve this?by tye (Cardinal) |
| on Jul 26, 2000 at 02:21 UTC ( #24364=note: print w/ replies, xml ) | Need Help?? |
|
Okay, this and merlyn's permuations code has been ticking in the back of my mind. Finally out popped a neat way to find all of the unique permutations of a set of (possibly) non-unique elements. For example, all of the unique permutations of the letters "h e l l o". Which is what I needed for solving this problem. So here is a script that, when given no arguments, solves the noted problem. When given arguments, it outputs all of the unique permutations of those arguments, in sorted order, without using extra memory to accumulate values or track context (not even recursing).
Remove the #OR# bits to have the solution provided sorted in an order I like better.
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||