En op 10 december 2002 sprak Tor Hildrum: > 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.
Also, it's more obfuscated than golf. perl -lne'sub a{print+local$*=$*.shift,a(@_)for(1)x@_};a/./g' is the golf version. This one takes input from STDIN, as requested. Same output, different order: perl -Xlne'sub a{print+local$*=pop.$*,a(@_)for(1)x@_};a/./g' > PS: In the real life code, I ended up using a CPAN module :) More than 95% of all CPAN modules are more than 95% too long. Lingua-EN-Words2Nums is a typical example. (-ugene -- Hackers do it with fewer instructions.