Woburn Challenge 1998
Episode 2: The Hutts Strike back (Will Han be Spared?)INPUT FILE: prob2.in
OUTPUT FILE: prob2.out
Han Solo is deep in debt to Pizza the Hutt and Atilla the Hutt, Jabba's lesser known but equally blobular cousins. Together, Jabba, Atilla and Pizza form a deadly trio known as the The Other Three Tenors. Pizza, being the nice blob that he is, has made Han an offer he can't refuse to rectify the situation. He has challenged Han to a game of bowling - if Han loses, he will face the ultimate punishment of being put in a holding cell listening to recordings of C3PO's infernal whining for the rest of his life. Unfortunately, the Hutt family have been cursed with no elbows and thus can't bowl; so instead they have hired Peter "Three Thumbs" Plachta to bowl for him.Your job is to write a program that will tally up the scores so that they can determine who wins.
In case you're unfamiliar with the rules of bowling, here's how it works:
INPUT
The first line of the input will be the number of bowlers.
Following this is the result of each throw by each bowler (X = Strike, / = Spare,
0..9=knocked # of pins down).
There may be anywhere between 1 and 5 bowlers given - each bowler will be on
a different line.
Note: There is no space between throws in a frame (so for the example below,
in the 1st frame, on the first throw, 2 pins were knocked down and on the second
throw, 2 more pins were knocked down).
Frames are separated using 1 hyphen.
If a strike was bowled in a frame, there is no 2nd throw in that frame and so
there is a blank space in the data file after the X to signify that there was
no 2nd throw.
OUTPUT
Output the total score of each player as shown in the example below:
Sample Input File
2 22-4/-X -55-42-X -X -4/-54-23 X -X -X -X -X -X -X -X -X -XXX
Sample calculation for player 1 (score for each frame is shown after considering
subsequent throws if strike/spare):
4 - 20 - 20 - 10 - 6 - 24 - 20 - 15 - 9 - 5 => total = 133
Sample for player
2 30 - 30 - 30 - 30 - 30 - 30 - 30 - 30 - 30 - 30 => total = 300 (maximum score)
Output for Sample Input
133 300