kradical / lottery-api

A typescript webserver that checks lottery tickets

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Interview Exercise

Your goal is to extend the functionality of this Node.js service.

Powerball is a popular US lottery game with draws twice a week. For the purposes of this exercise, a Powerball lottery "ticket" includes the date of the draw and one or more "picks". Each "pick" is a set of 5 integers (from 1-69) along with a 6th integer (the Powerball, from 1-26).

For example, a pick for the draw on 2017-11-09 might be:

02 14 19 21 61 25

Your application's API will accept data for a lottery ticket, and respond with whether each pick has won, the prize won per-pick, and the total of all prizes won on the ticket. It is up to you to design and build this API.

The Powerball winning numbers change on each "draw date". In order to determine a win or a loss, your application will have to retrieve the Powerball draw dates and winning numbers from the following public URL:

https://data.ny.gov/resource/d6yy-54nr.json

To calculate the prize, consult the prize matrix image below:

Powerball Rules

Exercise Rules

  • There is no time limit to this challenge.
  • Use your best discretion with the design and requirements, but you can ask questions.
  • You must use TypeScript and must extend this code base.
  • There is no need for a UI to solve this problem.
  • Follow modern TypeScript and Node best practices and conventions to the best of your ability.
  • You are free to add packages, tools or improvements to your project as you see fit.
  • We expect you to write the kind of feature you would put into production, including tests and documentation as you see fit.

Download

To checkout the source, you should clone it from GitHub! Don't fork it or other people will be able to see your solution. Instead clone it and then push it to your own private GitHub repo.

Installation

This app requires:

  • A Linux or MacOS Environment (Windows Untested)
  • Node.js LTS 10.9+

If you do not have node.js installed:

  1. Install NVM
  2. Install Node 10 nvm install 10.15.3
  3. Switch to Node 10 nvm use 10.15.3

Starting the App

From the checked-out application folder, run:

npm install

This will install dependencies.

npm start

You should see output like this:

ts-node index.ts
App listening on port 3000

You can then hit the default endpoint:

http://localhost:3000/

You should see something like this:

{
  "messsage": "Hello World"
}

To shutdown the server simply send a ^C.

Testing

To run the existing (sample) tests simply use:

npm test

You should see output like this:

 Test Suites: 3 passed, 3 total
 Tests:       5 passed, 5 total
 Snapshots:   0 total
 Time:        2.585s
 Ran all test suites.

Submission

Make your changes on a branch and then make a PR back to your private repo. That makes it easy for us to review your changes in one place. When you're ready for us to review your solution give these users access to your repo:

Contact

We encourage you to use your best discretion, but also to ask questions and communicate if you need it.

About

A typescript webserver that checks lottery tickets

License:Other


Languages

Language:TypeScript 100.0%