|The stupid question is the question not asked|
(Golf) Let's go bowlingby virtualsue (Vicar)
|on Aug 08, 2001 at 19:09 UTC||Need Help??|
[Update: The winners have been posted on my home node, along with a simple demo program which contains their code.]Tenpin bowling, to be precise (there are many bowling games with a variety of scoring rules). This was partly inspired by a chatterbox discussion many weeks ago. For those who have never had the pleasure, tenpin bowling is a game which consists of 10 frames, in each of which you are given two tries to knock down 10 pins.* If you succeed on the first try, it's a strike. If you succeed with the second try, it's a spare, otherwise you blew it. :)
Scoring per frame works as follows:
The maximum score in any one frame is 30. The minimum is 0. A game consisting of all strikes (AKA a 'perfect game') is 300. The 10th frame is "special". If a strike is thrown on the first ball, then the player gets two more throws (to satisfy the scoring rule above). Likewise, if a spare is achieved on the second ball of the 10th frame, then the player gets one more throw. This means that a game may consist of as few as 11 balls thrown (9 strikes in first 9 frames, then no strike or spare in the 10th) to a maximum of 21. So, given these rules, construct some code to score a game.
You can assume that you will get an array containing the pinfall for 10 frames, e.g.
(Update: The above data represents a game of 146)
Or, you can handle getting the pinfall data any way you want. I don't care, so long as the code calculates scores correctly.
*It also consists of nasty rented shoes and ugly shirts, the horror of which is only partially offset by the availability of bad beer