You are viewing a single comment's thread. Return to all comments →
a simple approach using python
even works for cases when x2 is not given to be greater than x1.
def kangaroo(x1, v1, x2, v2): if (x1<x2 and v1<=v2) or (x1>x2 and v1>=v2): return "NO" else: t=0 while (( min(x1,x2)+t*max(v1,v2) )<=( max(x1,x2)+t*min(v1,v2) )) : if ( min(x1,x2)+t*max(v1,v2) )==( max(x1,x2)+t*min(v1,v2) ): return "YES" t+=1 return "NO"
Seems like cookies are disabled on this browser, please enable them to open this website
Number Line Jumps
You are viewing a single comment's thread. Return to all comments →
a simple approach using python
even works for cases when x2 is not given to be greater than x1.