Spoiler - My solution

I’m really happy with this. I only had to scrap everything and start over once. And yes, the magic number 19 should be a variable declared at the top. I spotted that after posting.

public static string FormatRolls(List<int> rolls)
{
    int ballCount = 0;
    string output = "";

    for (int i = 0; i < rolls.Count; i++)
    {
        ballCount++;

        if (ballCount % 2 != 0)
        {
            if (rolls[i] == 10)
            {
                output += (ballCount < 19) ? " X" : "X";
                ballCount++;
            }
            else
            {
                output += rolls[i].ToString();
            }
        }
        else
        {
            output += (rolls[i - 1] + rolls[i] == 10) ? "/" : rolls[i].ToString();
        }
    }

    return output;
}
1 Like