Number line jumps solution

Problem statement

Link to problem

Lessons learned

  • Set up equations and solve by hand
  • Brute-force solutio and then think of edge cases

Solution

# Complete the kangaroo function below.
def kangaroo(x1, v1, x2, v2):
    if (x1-x2<0) and (v1-v2<0):
        return "NO"
    k = (x2-x1)/(v2-v1)
    if k.is_integer():
        return "YES"
    else: 
        return "NO"
    

Note: Fails on test case 10.