Skip to content

GabrielPRomero/location-task

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Problem

Write a program that solves the most suitable (with highest non-zero speed) network station for a device at a given point (x, y).

This problem can be solved in 2-dimensional space. Network stations have reach and speed that depends on the distance to the station.

A network station’s speed can be calculated as follows:

speed = (reach - device's distance from network station)^2 if distance > reach, speed = 0

Network stations are located at points (x, y) and have reach r:

x y reach
0 0 9
20 20 6
10 0 12
5 5 13
99 25 2

Print out the most suitable network station and the network speed from devices (x, y): (0, 0), (100, 100), (15, 10), (18, 18), (13, 13) and (25, 99)

Program should output the solution to these two cases:

● Best station found, output station location and speed

● No station within reach found, output error message

It can be in the form of:

“Best network station for point x,y is x,y with speed z” “No network station within reach for point x,y”

Example output from solution:

“Best network station for point 15,10 is 5,5 with speed 3.3111629250273373”

How to run solution

  1. Clone the code
  2. Change directory to src folder
  3. Run the location_task.js file with node "node location_task.js"

The results will be printed on the console.

How to run tests on the solution

  1. After cloning the code run "npm install"
  2. Install the Jest cli using "npm i jest-cli -g"
  3. Run "jest"

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published