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
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.