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 8% | |
#2 | 81 c. | Top 15% | |
#3 | 86 c. | Top 23% | |
#4 | 91 c. | Top 31% | |
#5 | 107 c. | Top 38% | |
#6 | 135 c. | Top 46% | |
#7 | 165 c. | Top 54% | |
#8 | 175 c. | Top 62% | |
#9 | 179 c. | Top 69% | |
#10 | 481 c. | Top 77% | |
#11 | 569 c. | Top 85% | |
#12 | 808 c. | Top 92% | |
#13 | 868 c. | Top 100% |