Coder Social home page Coder Social logo

upnxt-assignment-cloud's Introduction

Assignment: Bowling algorithm

The goal of this assignment is to implement the bowling scoring algorithm.
The rules of bowling can be found here.

The algorithm should be served on a HTTP server, which contains a single /compute endpoint. We will help you with the setup of the server, you can find instructions on how to get started below.

The assignment should take around three hours to complete.

Specification

Input

The input is a HTTP POST request to the /compute endpoint. The body is a JSON object where the "game" key will map to a value which represents a game of bowling. This value is an array which contains nine tupples and one triple, each representing a frame.

Output

The output is a HTTP response with status code 200. The body is a JSON object with a single "score" key. It contains a single integer which represents the total score of the game. In case the input is invalid, the server should instead return a HTTP response with status code 400.

Example

$ curl http://localhost:8080/compute \
  --request POST \
  --header "Content-Type: application/json" \
  --data '{"game": [[1,2],[3,4],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0,0]]}'

{"score":10}

Getting started

1. Install NodeJs

Click here to go to the NodeJs installer. It will install node, npm and npx.

2. Copy repository

Please refrain from forking or using 'upnxt-assignment-cloud' as a name.

You can make a copy of the repository with the following commands:

npx degit inthepocket/upnxt-assignment-cloud#main assignment
cd assignment
git init
git add .
git commit -m "init"

Afterwards create a public repository on GitHub, we recommend to use the autogenerated name. GitHub will provide you a snippet to push an existing repository from the command line.

3. Install dependencies

You will need to use npm, a package manager, to download all third-party modules:

npm install

A node_modules directory will appear which contains all dependencies.

4. Bootstrap the server

Finally, start the server to begin development. The server will automatically reload when files are modified.

npm start

It is possible to invoke your server with curl as shown in the example above. Alternatively, you can use any other HTTP client.

Note: It is the package.json file which contains the definition of dependencies and scripts.

Tips

  • Keep it simple, stupid.
  • Keep it readable. Code is read more often than written.
  • Keep it typed. Static analysis prevents most mistakes.

upnxt-assignment-cloud's People

Contributors

witodelnat avatar

Stargazers

 avatar

Watchers

Louis De jaeger avatar Bram Vandenholen 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.