Giter VIP home page Giter VIP logo

bowling's Introduction

Bowling Game Challenge

Requirements

  • PHP 7.1 is installed.
  • For safety, PHP 7.1.13 or above , since that is the requirement of Laravel 5.6
  • Make sure composer is installed and run composer install in project directory

Example Commands

php artisan bowling:play "[[5,2],[8,1],[6,4],[10],[0,5],[2,6],[8,1],[5,3],[6,1],[10,2,6]]"
php artisan bowling:play "[[10],[10],[10],[10],[10],[10],[10],[10],[10],[10,10,10]]"
php artisan bowling:play "[[1,1],[1,1],[1,1],[1,1],[1,1],[1,1],[1,1],[1,1],[1,1],[1,1]]"

php artisan bowling:play -h

Running the tests

vendor/bin/phpunit

vendor/bin/phpunit --testdox

Example Frames

Input: [[5,2],[8,1],[6,4],[10],[0,5],[2,6],[8,1],[5,3],[6,1],[10,2,6]]

Output: [7, 16, 26, 41, 46, 54, 63, 71, 78, 96]

Running Demo

Operation & Test Files Location

app/Console/Commands/PlayBowling.php
app/Bowling.php
tests/Features/SetInputFramesTest.php
tests/Features/ViewScoreHistoryTest.php

About This Game Repo For Below Coding Challenge

This test is to write a program for a ten-pin bowling game.

A bowler has ten frames to knock down pins. In each of one to nine frames, the bowler makes one or two throws while the tenth frame has up to three throws.

You program should be able to receive an array of arrays of pins knocked down by each throw as an input. Each number should always be an integer between 0 and 10. Each sub-array represents one frame of a game. The basic rules of this bowling game are:

  • No additional score for a spare.
  • If a bowler knocks down all ten pins on the first throw, it’s a strike. A strike is worth 10, plus the score in the next frame if the next frame is not a strike. If the next frame is also a strike, which means the bowler has made two strikes, then the score from the third frame is also added to the first frame.
    • Ex. 10 (first frame)+10 (second frame)+10 (third frame) results in the first frame with a score of 30.
    • Ex. 10 (first frame)+6 (second frame) results in the first frame with a score of 16.
  • If a strike is not made in a frame, the score of the frame is just the sum of pins knocked down.
  • The last frame has up to three throws. If a bowler had a strike on the first throw, the bowler is allowed to have one additional throw. So the bowler has three throws in total. If the bowler made two strikes he will still be able to do the last throw

Your program should display a list of integers representing the total scores at the end of each frame.

License

The Play Bowling Game Console is open-sourced software licensed under the MIT license.

bowling's People

Contributors

zawmyolatt 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.