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.
#!/bin/python3importmathimportosimportrandomimportreimportsys## Complete the 'kangaroo' function below.## The function is expected to return a STRING.# The function accepts following parameters:# 1. INTEGER x1# 2. INTEGER v1# 3. INTEGER x2# 4. INTEGER v2#defkangaroo(x1,v1,x2,v2):ifv1==v2:return"YES"ifx1==x2else"NO"if(x2-x1)*(v1-v2)<0:return"NO"if(x2-x1)%(v1-v2)==0:return"YES"return"NO"if__name__=='__main__':fptr=open(os.environ['OUTPUT_PATH'],'w')first_multiple_input=input().rstrip().split()x1=int(first_multiple_input[0])v1=int(first_multiple_input[1])x2=int(first_multiple_input[2])v2=int(first_multiple_input[3])result=kangaroo(x1,v1,x2,v2)fptr.write(result+'\n')fptr.close()
Cookie support is required to access HackerRank
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 →
THIS IS MY PYTHON CODE: