Git Product home page Git Product logo

hockey-challenge's Introduction

Net Purpose coding challenge

Setup

  • Ensure node.js is installed
  • Run npm install to install dependencies
  • Run npm test to run the unit tests

The task

Given a number , n, find the n highest and lowest scores in the given array. This task should take you no longer than 15-30 minutes.

The Net Purpose Hockey League (NPHL) is now in season! At the end of the season, the top n teams get promoted to the division above and the bottom n teams get relegated to the division below.

The division results are provided as an array of teams, as follows:

[
  {
    "name": "Rockets",
    "points": 64,
  },
  {
    "name": "Cardinals",
    "points": 77,
  },
  {
    "name": "Bruisers",
    "points": 51,
  },
  {
    "name": "Renegades",
    "points": 37,
  },
  {
    "name": "Porpoises",
    "points": 52,
  }
]

Write a function that returns a multi-line string showing the teams that will be promoted and relegated using the format below.

For an n value of 2, the results must be:

Promote:
[Highest scoring team]
[Second highest scoring team]

Relegate:
[Second lowest scoring team]
[Lowest scoring team]

For an n value of 3, the results must be:

Promote:
[Highest scoring team]
[Second highest scoring team]
[Third highest scoring team]

Relegate:
[Third lowest scoring team]
[Second lowest scoring team]
[Lowest scoring team]

There are some finished unit tests in src/index.spec.ts to get you started. There is an empty function in src/index.ts where you can write the implementation.

Constraints

  • There could be between 2 and 16 teams in a given division.
  • A team always consists of a name string and a points integer, which is always positive or 0.
  • If teams both in the top n and bottom n for the division, the promotion and relegation process will not work and the user must be notified of the problem.

Tips

  • We are interested in your implementation of the solution, not the unit test code. Please feel free to add unit tests to help with development though.
  • We are looking for clean code, which is easy to read and free of code smells.

Submitting the task

When you have completed the challenge, please upload your solution to GitHub, GitLab or similar. When you have done this, please share a link with us at [email protected]. If you have any problems, we can also accept the solution attached to an email.

hockey-challenge's People

Contributors

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