Determine whether a message can reach a destination router from a source router.
You are given a list of routers with their 2D location coordinates, a source router, a destination router and a range value. Each router that receives a message broadcasts it to the other routers in range, and whenever a router broadcasts a message it shuts down permanently. Write a method that determines whether a message starting at the source router can reach the destination router. Distance between routers is Euclidean distance.
Example: Router A at (0, 0), B at (0, 8), C at (0, 17), D at (11, 0), range 10, source A, destination D. A's message reaches B, B's message reaches C, but D never receives it.
Follow-up: discard message collisions. If the destination receives 2 or more messages at the same time, the message is considered collided and discarded, i.e. not reachable. Only messages that do not collide with others at the same time are reachable. Assume the time for a message to reach any router is proportional to the distance.
Expect follow-ups like
- How would you update the solution if messages that arrive at the destination at the same time collide and are discarded, assuming travel time is proportional to distance?


