Solution Judge's input Judge's output Clarifications Comments
Of course, since you may not know how to score a game of bowling either, Joe Junior has provided a description of the rules. The basic game consists of ten frames. In a frame, you get two chances to throw a ball down the alley and knock over as many pins as you can. There are ten pins standing at the beginning of a frame, and none are replaced after getting knocked over on the first ball, so the most pins you can knock over in a frame is ten. You get one point for each pin knocked over. In addition, there are two bonuses you can earn. If you knock over all ten pins on your first ball of the frame, you have scored a ``strike''; besides the ten points for the pins, your score in this frame is increased by the total number of pins knocked down with your next two balls. Those next two balls are usually part of another frame (or two) and score points in that frame (or those frames) as well. If you knock over all ten pins in a frame, but it takes you two balls to do it, you have scored a ``spare''; in addition to your ten points for pins knocked down, your score for the frame is increased by the number of pins you knock down on your next ball. Of course, those pins also count as part of the next frame. If you score a spare (or strike) in the final (tenth) frame, you are entitled to one (or two) extra balls to determine your tenth frame bonus. A perfect game scores 300 points, because each frame scores 30, 10 for knocking down 10 pins, and 20 for knocking down 20 pins with the next two balls combined.
Now, are you ready to sign on to write the software?
|81||Knocked down 8 pins on the first throw, one on the next|
|7/||Knocked down 7 pins on the first throw, then the rest|
|X||Knocked down all pins on the first throw|
|9-||Knocked down 9 pins on the first throw, none on the next|
|8/X||Knocked down 8 pins on the first throw of frame 10, then the rest, then all the pins on the bonus throw|
|X-/||Knocked down ten pins on the first throw of frame 10, then missed all the pins on the first bonus throw and knocked them all down on the second bonus throw|
The second output line shows cumulative scores. The cumulative score for the first frame is just the score for pins knocked down in the frame, plus bonus points if they apply. The cumulative score for any other frame is the cumulative score for the previous frame plus the score for pins knocked down in that frame, plus the bonus points that may have been earned for a strike or spare in this frame. It is possible to have markings on line one for a frame, but no score on line two, in the event that the frame is a strike or spare but the bonus points for the frame aren't yet known.
The format for this output requires that the bowler's name be left-justified. The fields for each frame are three characters wide, with a space separating each field. The fields begin in columns 14, 18, 22, and so on. The record of the throws in the first line is left justified in its field. The cumulative score is right justified in its field. There is a blank line after each pair of output lines.
Chuck 9/ 9/ 9/ 9/ 9/ 9/ 9/ 9/ 9/ 9/9
19 38 57 76 95 114 133 152 171 190
Solly X X
X X X X X X
30 60 90 120 150 180 210 240 270 292
Lothar -/ -/ -/
Brutus 54 8/ 4/
9 23 34
McGillicuddy X X 9/
Homer X -/
X X X
20 40 70
Barney X X
X X X X X X
30 60 90 120 150 180 210 240 269 289