There is an open jar and a fly inside it. That fly is flying from side to side frantically because it really wants to get away from there. Your task is to estimate whether it will succeed in its attempts (return True) or not (return False).
So what do we got? The jar is represented by a rectangle in the drawing above. It has width W and height H. The jar has a hole of the size d. Our fly can escape through it. The hole is always placed on the top of the jar and the jar is symmetrical. Point O is the origin, the y-axis matches the jar's left side and the x-axis matches the jar's bottom side. The wall thickness is negligible.
Initial position of the fly is defined by x0 and y0, which are assigned arbitrary. But it's guaranteed that the fly is inside the jar by the time we start to observe it. In the very beginning the fly is flying linearly, Vx and Vy are a horizontal and vertical components of the velocity vector respectively. When the fly hits a wall, it deflects from it and fly in the opposite direction (like a billiard ball). The drawing above illustrates how it works. Also, there's one tiny detail: after each collision the fly loses 5% of its initial stamina, getting tired (velocity remains the same though). So after 20 collisions the fly becomes completely exhausted. The fly's size is negligible.
Input: Two lists of integers:
- the first contains jar's dims [W,...
True or False.
escape([1000, 1000, 200], [0, 0, 100, 0]) == False escape([1000, 1000, 200], [450, 50, 0, -100]) == True
All dimensions are given in abstract units, velocities are given in units/sec.