Intersecting hoppers

Two grasshoppers on the x x -axis start at an initial coordinate x 1 x_{1} and x 2 x_{2} start at the same time and hop at a rate of v 1 v_{1} meters/jump and v 2 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 ) (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 2, 5, 0, 7 they will reach each other at x = 30 x=30 .

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


The answer is 10.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

1 solution

Piyush Patnaik
Jun 4, 2019

I think the ans would be 208 instead of 10 as per a checking criteria (x2-x1)/(v1-v2) shld be 0 or positive......If I am wrong plzzzz post how to solve

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...