Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: (tye)Re4: (Golf) Let's go bowling (105)

by petral (Curate)
on Aug 21, 2001 at 23:38 UTC ( [id://106719]=note: print w/replies, xml ) Need Help??


in reply to (tye)Re4: (Golf) Let's go bowling (105)
in thread (Golf) Let's go bowling

Yes, but since you're now counting the frames (and replacing ./ and X later) you don't have to match the whole string!
Much simpler ( 84 chars):
sub bowl { ($_,$n)=@_; # 11 s#./(?=(.))|X(?=(..))|..#$&.($n++<9&&$1.$2)#ge; # 47 s#./|X#9#g+map{(1)x$_}/./g # 26 } # ___ # 84
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 { $_=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
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 m#(./(?=(.)(?{$_.=$2}))|X(?=(..)(?{$_.=$3}))|..){9}#; # 53 s#./|X#55#g; # 12 s/\B/+/g; # 9 eval # 4 } # ___ # 85

   p

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://106719]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (7)
As of 2024-04-23 13:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found