A simple ten-pin bowling score calculator.
pip install -e .
from bowling_scorer import BowlingGame
game = BowlingGame()
game.roll(10) # strike
game.roll(7)
game.roll(3) # spare
game.roll(9)
print(game.score())Or run the CLI, passing the game as a Python list literal. A roll is a
single-character string: a digit "0"-"9", "/" for a spare, or "X"/"x"
for a strike.
Rolls-based (a flat list of rolls):
bowling-scorer '["8","/","5","4","9","0","X","X","5","/","5","3","6","3","9","/","9","/","X"]'
Frames-based (a list of frames, each a list of rolls):
bowling-scorer '[["8","/"],["5","4"],["9","0"],["X"],["X"],["5","/"],["5","3"],["6","3"],["9","/"],["9","/","X"]]'
Both forms of the game above print:
149
A game with fewer than 10 frames is scored as a partial game:
bowling-scorer '[["8","/"],["5","4"]]'
24 (partial game: 2 of 10 frames)
pip install -e ".[dev]"
pytest
Each run also writes a self-contained HTML report to pytest_report.html.