Git Product home page Git Product logo

bowling-score-calculator's Introduction

Bowling Score Calculator

Done as part of a TDD exercise.

Objective

Get a string of one bowling game line, and return score.

Example: '20 00 X 1/ 03 04 00 00 00 70' should return: 46

Rules

There are 10 pines you try to knock down in each frame. A strike - knock all 10 pins with the first ball. A spare - knock all 10 pins with the second ball (2 throws). Each games consists of ten frames. If you bowl a strike in the tenth frame, you get two more balls. If you throw a spare, you get one more ball.

Score

Scoring is based on the number of pins you knock down. However, if you bowl a spare, you get to add the pins in your next ball to that frame. For strikes, you get the next two balls.

Input

  • Line string has 10 (or 11) frames separated by a single space.
  • Each frame has 2 (or 1) characters - one for each throw.
  • The 1st can be a digit 0-9 or X to represent a strike.
  • The 2nd can be a digit 0-9 or / to represent a spare.

Examples:

  • 02 00 00 00 00 30 00 00 00 07 (Score: 12)
  • 20 00 X 1/ 03 04 00 00 00 70 (Score: 46)
  • 20 00 X 1/ 03 04 00 00 00 0/ 1 (Score: 50)
  • 12 4/ 20 X 35 X X 9/ 4/ X 81 (Score: 145)

Example implementation: https://www.sportcalculators.com/bowling-score-calculator (no need for this GUI).

bowling-score-calculator's People

Contributors

izmirli avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.