We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
There is no limit to jumps, BUT there are constraints to their distance between them and jump length, right? So by taking the "worst case" scenario which would be:
x1 = 0
v1 = 2
x2 = 10000
v2 = 1
it will take 10 000 jumps for the first kangaroo to catch up with the other one, any more jumps is impossible under these constrainst, therefor the loop solution is valid.
But, I agree that the "(x1 - x2) % (v2 - v1) == 0" solution is neater ;)
Number Line Jumps
You are viewing a single comment's thread. Return to all comments →
There is no limit to jumps, BUT there are constraints to their distance between them and jump length, right? So by taking the "worst case" scenario which would be:
x1 = 0
v1 = 2
x2 = 10000
v2 = 1
it will take 10 000 jumps for the first kangaroo to catch up with the other one, any more jumps is impossible under these constrainst, therefor the loop solution is valid.
But, I agree that the "(x1 - x2) % (v2 - v1) == 0" solution is neater ;)