in reply to Re: (tye)Re2: (Golf) Let's go bowling (98!)
in thread (Golf) Let's go bowling
Darn. I noticed elsewhere in the thread about being sure to not count the bonus balls twice but missed the stuff about there being no good trick to tell whether X\d\d$ is a final frame with bonus balls or just the two final frames (other than counting frames). ):
I really didn't want to hard-code the number of frames because sometimes I'll bowl a "short game" when we run out of time. So here is an entry at 113 strokes that optionally lets you specify how many frames you shortened your game (you can even pass in a negative value for "extra long games"):
This even allowed me to add a test suite that shows the score at each frame. - tye (but my friends call me "Tye")sub bowl { ($_,$n)=@_; s#(\d)(\d|/(?=(.)))|X(?=(..))|.# ($3.$4?"X$3$4":$1.$2,"")[9<$n++]#ge; s#./#X#g; map{(y.X.a.)x hex}split// } chomp( @ARGV=<DATA> ) if ! @ARGV; for my $line ( @ARGV ) { print "$line = ", 0+bowl($line), "\n "; for( 0..9 ) { print " ",0+bowl($line,9-$_); } print $/; } __END__ 81633470434/72813/62 81633470434/72813/X18 X00X00X00X00X00 00X00X00X00X00X00 X11X11X11X11X11 11X11X11X11X11X11 5/63XX7043X4/813/6
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: (tye)Re3: (Golf) Let's go bowling (113)
by petral (Curate) on Aug 14, 2001 at 20:41 UTC | |
by tye (Sage) on Aug 15, 2001 at 03:58 UTC | |
by petral (Curate) on Aug 21, 2001 at 23:38 UTC |