Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Test Driven Development Sample
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Isaac Gouy  
View profile  
 More options Dec 4 2003, 2:57 am
Newsgroups: comp.object
From: ig...@yahoo.com (Isaac Gouy)
Date: 3 Dec 2003 23:57:33 -0800
Local: Thurs, Dec 4 2003 2:57 am
Subject: Re: Test Driven Development Sample

ig...@yahoo.com (Isaac Gouy) wrote in message <news:ce7ef1c8.0311241350.3d6a6b0e@posting.google.com>...

We can use a similar approach to accumlate the intermediate bowling
scores for a possibly incomplete sequence of valid throws - update the
sequence after each throw and recalculate the scores.

Start = scores [10, 4,6, 10, 4,6, 10, 4,6, 10, 4,6] [] 0 0

scores pins a total 10    = a  
scores []   a total count = a
scores [x]  a total count = a

scores [x,y] a total count
   | x == 10   = a
   | x+y == 10 = a
   | otherwise = a++[total+x+y]

scores [x,y,z:rest] a total count
   | x == 10   = scores [y,z:rest] (a++[total+x+y+z]) (total+x+y+z)
(count+1)
   | x+y == 10 = scores   [z:rest] (a++[total+x+y+z]) (total+x+y+z)
(count+1)
   | otherwise = scores   [z:rest] (a++[total+x+y])   (total+x+y)  
(count+1)

The answer in this case would be [20,40,60,80,100,120,140] - the 8th
total for the spare cannot be calculated until the next throw.

best wishes, Isaac


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.