Intersecting hoppers

Computer Science Level 4

Two grasshoppers on the \(x\)-axis start at an initial coordinate \(x_{1}\) and \(x_{2}\) start at the same time and hop at a rate of \(v_{1}\) meters/jump and \(v_{2}\) meters/jump respectively. Given the starting locations and movement rates of each grasshopper it is required to find if they'll ever land at the same location.

In the text file is given a set of spaced integers \((x_{1}, v_{1}, x_{2}, v_{2})\) representing the starting locations and movement speed of the grasshoppers, in how many of the cases will they land at the same location?

Details and Assumptions

  • For the case \(2, 5, 0, 7\) they will reach each other at \(x=30\).

  • For the case \(1, 5, 4, 5\) they will never be able to reach each other. Rd


Problem Loading...

Note Loading...

Set Loading...