• + 1 comment

    Explanation: we have to print yes iff { x1+v1 x n= x2+v2 x n } we have constraint that x1< x2 so => ( v1-v2 )n=x2-x1 => n=(x2-x1)/(v1-v2)................n must be positive so v1>v2 and n is whole so the remainder should be 0 hence the code is as follows:

    def kangaroo(x1, v1, x2, v2):
        # Write your code here
        if(v1>v2 and ((x2-x1)%(v1-v2)==0)):
            return("YES")
        else:
            return('NO')