Skip to content

Latest commit

 

History

History
33 lines (18 loc) · 2.08 KB

File metadata and controls

33 lines (18 loc) · 2.08 KB

Back-end code challenge alt Batlogo

Batman needs your help!

You should create an algorithm for the Batcave supercomputer that should be able to calculate the probability of a super villain attacking Gotham.

This algorithm must have an address, a location or a coordinate (the clock tower or the current position of the villain, for example). When the input is an address or a location, you must transform it into a coordinate (using Google, Maplink, Yahoo, Bing, etc).

You will use this coordinate to determine the probability of an attack on nearby locations within the Gotham boundaries.

The probability is given by the linear distance between the villain and the target, that is, the closer, greater is the probability of an attack. To calculate the linear distance use the Haversine Formula. Consider the radius of the Earth as 6371km, and to facilitate disregard the elevation in the calculations!

The range of action of the villain is 2km, and the maximum probability of attack is 95% in cases where the result is greater than that. (After all, who would understand what goes on inside the head of a super villain ?!)

Remember, Batman is very demanding, even with the quality of the codes. Surprise him!

Input

The villain address, location or coordinate.

Sample:

  • GET /address?q=Rua Fidêncio Ramos, 302 - São Paulo
  • GET /location?q=Maplink
  • GET /coordinate?q=-23.594684,-46.685900

The coordinate must be within the Gotham city boundaries, otherwise it must be notified in some way.

Output

Each response should contain the location of the villain and the information about the locations that may be under attack.

Sample.