Git Product home page Git Product logo

ping-pong-is-fun's Introduction

ALGO-RITHMS CHALLENGE // PING PONG IS FUN

1. Getting started

https://github.com/bmuntper/Ping-pong-is-fun.git

Fork this repo and then git clone your forked repo to your computer. Once you're happy with your solution, git push and submit a pull request at https://github.com/bmuntper/Ping-pong-is-fun.git.

2. Challenge

Playing ping-pong can be really fun! Unfortunatelly after a long and exciting play you can forget who's service turn it is. Let's do something about that!

Write a function that takes the current score as a string separated by : sign as an only parameter and returns "first" or "second" depending on whose service turn it is.

If the game has finished it should return "finished".

We're playing old-school, so the rule is that players take turn after every 5 services. That is until the score is 20:20 - from that moment each player serves 2 times in his turn.

There's no need to check if the passed parameter is valid - the score will be always provided in correct syntax - that won't be the case.

P.S. The game ends when one of the players reaches 21 points with minimum 2-point lead. If there's a current score of 20:20, the winner will be the first player to reach 2-point lead.

2.1. Examples

service("0:0") // => "first"
service("3:2") // => "second"
service("21:20") // => "first"
service("21:22") // => "second"
service("21:18") // => "finished"

2.2. Testing your solution

To test your solution, run npm i in the root directory and then run npm t to run the automated tests.

2.3. Submitting your solution

To submit your solution:

  1. If you're working on a forked repo, push your changes to your forked repo and submit a pull request to this repo.

ping-pong-is-fun's People

Contributors

bmuntper avatar

Watchers

 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.