Wednesday, August 05, 2009 9:16 AM
Maurits
Bad Perl: locker problem
Bad Perl solution to the "print the open lockers" problem:
perl -e"print join', ',map{$_*$_}1..sqrt pop" 100
54 characters. I prefer this to the 53-character solution obtained by omitting the space after the first comma.
EDIT: 49 characters:
perl -e"print map{$_*$_,' '}1..sqrt pop" 100
EDIT: 48:
perl -e"print map{$_*$_.$/}1..sqrt pop" 100
EDIT: 47:
perl -e"map{print$/.$_*$_}1..sqrt pop" 100
I still think "say" is cheating but it does afford this very short solution:
perl -E"map{say$_*$_}1..sqrt pop" 100
EDIT: Apparently I need to learn how to count. Counts above are off. Anyway, 41:
perl -e"print$_*$_,$/for 1..sqrt pop" 100