Björn Helgason wrote:
> In princip what you have is three figures for every throw

Not for every throw: only if you achieve ten points in a
frame does the frame get the benefit of three rolls of the
ball.  If you score less than that the frame gets the benefit
of only two rolls of the ball.

That said, this is a good observation, and allows me to simplify
my approach to scoring:

shift=:|.!.0"0 1
frame=: (*.10 >: +/\)@(10&= +. [: ~:/\ 10>])
scores=: frame(](]+10&<:@]*2&[EMAIL PROTECTED])*+(*1&shift))]
NB. scores looks better the way J's linear form displays 
NB. it, but I'm worried about email line wrap.

empty_case=: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
open_case=: 9 0 8 1 7 2 6 3 5 4 4 5 3 6 2 7 8 1 0 9
spare_case=: 9 1 8 2 7 3 6 4 5 5 4 6 3 7 2 8 1 9 8 2 1
strike_case=: 10 10 10 10 10 10 10 10 10 10 10 10
alt_case=: 9 1 10 8 2 10 7 3 10 6 4 10 5 5 10 4 6 10

assert 0=+/scores empty_case
assert 90=+/scores open_case
assert 145=+/scores spare_case
assert 300=+/scores strike_case
assert 200=+/scores alt_case

-- 
Raul

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to