Giter Site home page Giter Site logo

bowling's Introduction

Kata Bowling.

The goal of this kata is to calculate the score of a Bowling game. The script will read a string containing every run of a player and will output the final score.

We will consider the following:

  • the format of the string passed to the script is valid
  • we only want the final score

Here is the list of rules for the calculation of the score of a Bowling ten-pin game:

  • A game is divided in 10 frames
  • In a frame the player has two balls to knock down the pins
  • The score after each round is the number of koncked down pins
  • If, after the first ball of a frame, every pin are knocked down it is a strike and the score is 10 points plus the score of the next two balls
  • If, after the second ball of a frame, every pin are knocked down it is a spare and the score is 10 points
  • On the last frame, if the player do a strike or a spare, then he can play two or one more ball. The score of each bonus balls are added to the score of the latest frame.

Examples:

Input: "XXXXXXXXXXXX" (12 balls: 12 strikes) Output: 300 Calcul: 10+10+10 + 10+10+10 + 10+10+10 + 10+10+10 + 10+10+10 + 10+10+10 + 10+10+10 + 10+10+10 + 10+10+10 + 10+10+10

Input: "9-9-9-9-9-9-9-9-9-9-" (20 balls: 9 knocked down on the first ball of each frame, 0 on the second one) Output: 90 Calcul: 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9 + 9

Input: "5/5/5/5/5/5/5/5/5/5/5" (21 balls: 10 spares + 5 pins on the bonus ball) Output: 150 Calcul: 10+5 + 10+5 + 10+5 + 10+5 + 10+5 + 10+5 + 10+5 + 10+5 + 10+5 + 10+5

Credits

http://www.developpeur-agile.fr/2012/12/21/exercice-kata-bowling/ (french)

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.