Welcome to MSDN Blogs Sign in | Join | Help

Browse by Tags

All Tags » Perl   (RSS)
Sorry, but there are no more tags available to filter with.
http://programmingpraxis.com/2009/10/09/calculating-pi/ > perl -e"print 4/(map{$n+=rand()**2+rand()**2<1}1..pop)*$n" 5000 3.1336 59 characters , plus arguments. Read More...
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 Read More...
Another programming contest asks to solve the Josephus problem . Bad Perl solution (83 characters... so close...) >perl -e" @_=(1..$ARGV[0]);++$c%$ARGV[1]?$i++:splice@_,$i%=@_,1while$#_;print@_ " 40 3 28 EDIT: got it down to 80. >perl -e" @_=(1..shift);++$c%$ARGV[0]?$i++:splice@_,$i%=@_,1while$#_;print@_ Read More...
I found this programming contest interesting: here's what I've got. perl -e " ($a,$b)=@ARGV;map{$c+=$_*$b}grep{$a&$_}map{1<<$_}(0..log($a)/log 2);print$c " 7 19 I'm calling this a one-liner because the part between the quotes is less than 80 Read More...
Perl has an ambivalent reputation. It can be used to write short, hard-to-read programs: perl -e "print join er,reverse',','l hack',' P','Just anoth'" Or it can be used to write very-easy-to-read programs which are a better link into the developer's mind than programs in any other language. Read More...
 
Page view tracker