FindingEnemyship

c3

c2

r1

c1 c4

r0

c5


Q. The spaceship traveled from r0 to r1. How to compute to find the rightmost enemy ship (c5) with respect to the trajectory (r0-r1)?

example data:

r0 = (1, 4)
r1 = (3, 2)
positions = [(1, 6), (2, 6), (5, 2), (2, 0), (1, 2)]

The answer should be (1, 2).