Note: Edited to correct issues after folks pointed out things I didn’t notice as it was late at night.
There is an assumption that any (bowl >= 18) is the 10th frame. That is a FALSE assumption. Here is a simple example:
Frame: 1 2 3 4 5 6 7 8 9 10 10 10
Frame Score: 10 10 10 10 10 10 10 10 10 10 10 10
Bowl: 1 2 3 4 5 6 7 8 9 10 11 12
In reality, the 10th frame can have bowls between 10-21. Note: Ben’s final solution does address this issue by inserting into the data stream on the fly. There are other solutions that will work as well.
I thought my last version of the code was correct, but it wasn’t.
So I copied all the “Verification” tests from the score master tests and ported them over.
To be fair, this is a difficult problem. I have 30 years of experience as a professional Software Engineer, and this was difficult for me.
Here is an alternate solution:
https://pastebin.com/UJnm8NU6
Hope this helps,
Dan