in reply to (Golf) Let's go bowling
Here's my best solution:
126 characters. (Or 125, if $r is replaced by a punctuation variable, since a space could then be eliminated.)sub score { my$s;sub S{$_[0]=~X?10:$_[0]}$s+=($l=shift)=~X?10+($_[1]eq'/'?10:S($_[ +0])+S$_[1]):($r=shift)eq'/'?10+S$_[0]:$l+$r for 1..10;$s }
During a Chatterbox discussion, tye suggested using a regex to parse the score. This sounded promising, but unfortunately I ended up with a longer solution.
145 characters.sub score { $"=my$s;sub S{$_[0]=~X?10:$_[0]}$S="@_";$S=~/(X)(?=(.)(.))|(.\/)(?=(.) +)|(.)(.)/g,$s+=$1?10+($3eq'/'?10:S($2)+S($3)):$4?10+S($5):$6+$7for 1. +.10;$s }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(tye)Re: (Golf) Let's go bowling
by tye (Sage) on Aug 11, 2001 at 12:00 UTC | |
by tye (Sage) on Aug 13, 2001 at 19:27 UTC | |
by petral (Curate) on Aug 14, 2001 at 01:59 UTC | |
by tye (Sage) on Aug 14, 2001 at 03:29 UTC | |
by petral (Curate) on Aug 14, 2001 at 20:41 UTC | |
| |
|
Re: Re: (Golf) Let's go bowling
by Brovnik (Hermit) on Aug 09, 2001 at 03:17 UTC | |
by tilly (Archbishop) on Aug 09, 2001 at 04:45 UTC | |
by virtualsue (Vicar) on Aug 09, 2001 at 14:25 UTC | |
by tilly (Archbishop) on Aug 09, 2001 at 16:50 UTC | |
by rchiav (Deacon) on Aug 09, 2001 at 17:38 UTC | |
by virtualsue (Vicar) on Aug 15, 2001 at 14:15 UTC | |
by chipmunk (Parson) on Aug 14, 2001 at 02:23 UTC |