in reply to (tye)Re4: (Golf) Let's go bowling (105)
in thread (Golf) Let's go bowling
And here's a little bit more complicated one which passes strict and -w (and yes, I do have other things I'm supposed to be doing with my time):sub bowl { ($_,$n)=@_; # 11 s#./(?=(.))|X(?=(..))|..#$&.($n++<9&&$1.$2)#ge; # 47 s#./|X#9#g+map{(1)x$_}/./g # 26 } # ___ # 84
update(5sep): Actually, here's a pretty straightforword one for perl 5.6.0 and higher that passes -w and use strict at 85 chars:sub bowl { $_=pop; # 7 $a=()=/\d\d\B/g; # 16 s#(?=./(.)|X(..))#$a++<9&&($2||$1)#ge; # 38 s#./|X#55#g; # 12 s/\B/+/g; # 9 eval # 4 } # ___ # 86
sub bowl { $_=pop; # 7 m#(./(?=(.)(?{$_.=$2}))|X(?=(..)(?{$_.=$3}))|..){9}#; # 53 s#./|X#55#g; # 12 s/\B/+/g; # 9 eval # 4 } # ___ # 85
|
|---|