Code Monkey home page Code Monkey logo

TDD Bowling Kata

Setup

Clone the repository

git clone [email protected]:tobywinter/tdd-bowling.git

Install all dependencies

npm i

Run the Tests

npm test

Resources

To check your working:

https://www.bowlinggenius.com/


Instructons

Write a program to calculate the score of a game of Ten-Pin Bowling.

Input: a string representing a bowling game score (* scoring rules following).

Output: the score as integer.

Conventions:

  • X indicates a strike

  • / indicates a spare

  • - indicates a miss

  • | indicates a frame boundary

  • The characters after the || are bonus balls

Examples

Examples:

score string total
X|X|X|X|X|X|X|X|X|X||XX 300 [10 frames x 30]
9-|9-|9-|9-|9-|9-|9-|9-|9-|9-|| 90 [10 frames x 9]
5/|5/|5/|5/|5/|5/|5/|5/|5/|5/||5 150 [10 frames x 15]
X|7/|9-|X|-8|8/|-6|X|X|X||81 167

Scoring Rules

  • Each game, or "line" of bowling, includes ten turns, or "frames" for the bowler.
  • In each frame, the bowler gets up to two tries to knock down all ten pins.
  • If the first ball in a frame knocks down all ten pins, this is called a "strike". The frame is over. The score for the frame is ten plus the total of the pins knocked down in the next two balls.
  • If the second ball in a frame knocks down all ten pins, this is called a "spare". The frame is over. The score for the frame is ten plus the number of pins knocked down in the next ball.
  • If, after both balls, there is still at least one of the ten pins standing the score for that frame is simply the total number of pins knocked down in those two balls.
  • If you get a spare in the last (10th) frame you get one more bonus ball. If you get a strike in the last (10th) frame you get two more bonus balls.
  • These bonus throws are taken as part of the same turn. If a bonus ball knocks down all the pins, the process does not repeat. The bonus balls are only used to calculate the score of the final frame.
  • The game score is the total of all frame scores.

Toby Hasler-Winter's Projects

dayjs icon dayjs

⏰ Day.js 2KB immutable date library alternative to Moment.js with the same modern API

gilded-rose icon gilded-rose

An approach to the famously gilded plant based kata.

jackal icon jackal

Consumer Driven Contracts Microservice

katalog icon katalog

A collection of katas for quick start exercises

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.