Permutations.
[email protected] (Tor Hildrum)
| Newsgroups | perl.golf |
|---|---|
| Message-ID | <BA1B25A6.16268%[email protected]> |
From a game:
You draw a random number of random letters and have to use all of them to
create words.
The problem:
Get the random number of letters on STDIN and print out all permutations on
STDOUT. (input matching /^[a-z]{3,16}$/ )
I'm currently at 200+ using a couple of nested for-loops and to much time,
which is basically why I was curios what you guys could come up with.
I found this on the perl-beginner list:
Perl -e
'*,=sub{print+local$*=$*.$_[$_],$/,&,(@_[1+$_..$#_])for$#..$#_};&,(1..5)'
By Paul Johnson, which isn't to shabby, but not really up to specs.
Anyone?
PS: In the real life code, I ended up using a CPAN module :)
Tor