Calculate the score of a bowling game.
Given an array of integers representing the number of pins knocked down in each frame of a bowling game, return the total score for the game.
A bowling game consists of 10 frames, in each frame the player has two opportunities to knock down 10 pins. The score for the frame is the total number of pins knocked down, plus bonuses for strikes and spares.
In the tenth frame a player who rolls a spare or strike is allowed to roll the extra balls to complete the frame. However no more than three balls can be rolled in the tenth frame.
Example: For the following frames:
[[10],[7,3],[9,0],[10],[0,8],[8,2],[0,6],[10],[10],[10,8,1]]
The score should be 167
.
# | Size | % | Users |
---|---|---|---|
#1 | 79 c. | Top 17% | |
#2 | 82 c. | Top 33% | |
#3 | 107 c. | Top 50% | |
#4 | 165 c. | Top 67% | |
#5 | 179 c. | Top 83% | |
#6 | 569 c. | Top 100% |