suraniap's blog

By suraniap, history, 8 months ago, In English

Find shortest distance out of a convex area.

We have our initial starting coordinates sx, sy. We're given an API that we can call which for x and y floats returns a bool which represents if the specific point is inside the area. (def uber_has_surge(x:float, y:float) -> bool)

Find the shortest distance out of the surge pricing area in a minimum number of API calls. (assume interactive)

I thought about trying to call with 4 directions and have a circle which represents max distance that might be the answer. The problem is that this is still brute force.

Another idea would be to find a boundary point, and then do binary search on polar coordinates, but I don't understand exactly how that might work?

Full text and comments »

  • Vote: I like it
  • +5
  • Vote: I do not like it