in reply to (Golf) Let's go bowling
Here is my solution (176 chars if data is joined in a single string in $_). Do you have a test suite?
Hope it's correct.$_ = join '', @b; s#(.)/(.)$#$1.(10-$1).$2#e;s# ?#a#g; s#XaXaXa$#10a10a10a#;s#Xa(\da\da)$#10a$1#; 1while s#Xa(\d+)a(\d+)#10a$1a$2a$1a$2#|| s#(\d+)a/a(\d+)#"$1a".(10-$1)."a$2a$2"#e; $s+=$_ for/\d+/g; print "$_: $s\n";
Aziz,,,
update:removed an extra $1 at the end of line 2 and added a missing 'a'. Score: 176 from 177
Major Update:
That code was wrong. Here is an update that works for the test cases: (score 131)
update:wrote it in sub form: score 144
CreditTo dragonchild for providing the test casesprint score(join'',qw(5 / 6 3 X X 7 0 4 3 X 4 / 8 1 3 / 6)),"->146\n"; print score(join'',qw(X X X X X X X X X X X X)), "->300\n"; print score(join'',qw(0 / X 0 / X 0 / X 0 / X 0 / X 0 /)),"->200\n"; print score(join'',qw(X 0 / X 0 / X 0 / X 0 / X 0 / X 0)),"->200\n"; sub score={ # 1 2 3 4 5 6 #234567890123456789012345678901234567890123456789012345678901234567890 ($_,$s)=@_;1while s#(.)/(.)#$1.($1<1?'x':10-$1)."\L$2y".$2#e||s#X(\d\d +)#x$1$1#||s#X(..)#"x\L$1z".$1#e||s#(y.|z..)$##||s#x#55#;$s+=$_ for/\d +/g;$s ##### }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: (Golf) Let's go bowling
by dragonchild (Archbishop) on Aug 08, 2001 at 22:35 UTC |