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 14% | |
#2 | 81 c. | Top 29% | |
#3 | 107 c. | Top 43% | |
#4 | 165 c. | Top 57% | |
#5 | 175 c. | Top 71% | |
#6 | 179 c. | Top 86% | |
#7 | 569 c. | Top 100% |