Answered step by step
Verified Expert Solution
Question
1 Approved Answer
The first kangaroo starts at location x1 and moves at a rate of v1 meters per jump. The second kangaroo starts at location x2 and
The first kangaroo starts at location x1 and moves at a rate of v1 meters per jump. The second kangaroo starts at location x2 and moves at a rate of v2 meters per jump. You have to figure out a way to get both kangaroos at the same location at the same time. If it is possible return YES otherwise return NO.
The correct code is below. I dont understand the line if(v1>v2 and diff % (v1-v2)==0)
and why do we have diff%(v1-v2)==0? also why must v1>v2? also why diff=x2-x1 in the beginning?
def kangaroo (x1,v1,x2,v2): diff =x2x1 if (v1>v2 and diff %(v1v2)==0): return "YES" else: return "NOStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started