You are viewing a single comment's thread. Return to all comments →
def kangaroo(x1, v1, x2, v2): # Write your code here p1 = x1 p2 = x2 distance = x2-x1 ans = 'NO' while p1<=p2 and distance<=x2-x1: if p1==p2: ans = 'YES' break else: p1 = p1 + v1 p2 = p2 + v2 distance = p2-p1 return(ans)
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 →
def kangaroo(x1, v1, x2, v2): # Write your code here p1 = x1 p2 = x2 distance = x2-x1 ans = 'NO' while p1<=p2 and distance<=x2-x1: if p1==p2: ans = 'YES' break else: p1 = p1 + v1 p2 = p2 + v2 distance = p2-p1 return(ans)