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.
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)
● Best station found, output station location and speed
● No station within reach found, output error message
“Best network station for point x,y is x,y with speed z” “No network station within reach for point x,y” “Best network station for point 15,10 is 5,5 with speed 3.3111629250273373”- Clone the code
- Change directory to src folder
- Run the location_task.js file with node "node location_task.js"
The results will be printed on the console.
- After cloning the code run "npm install"
- Install the Jest cli using "npm i jest-cli -g"
- Run "jest"