Question: You should complete the function and ensure it produces the correct output against all test cases possible within the constraints highlighted. The runtime of the

You should complete the function and ensure it produces the correct output against all test cases possible within the constraints highlighted. The runtime of the program is important so it is best to use an algorithm in the code which will not timeout

You should complete the function and ensure it produces the correct outputagainst all test cases possible within the constraints highlighted. The runtime of

Number Line Jumps Problem Submissions Leaderboard Discussions Fin You are choreographing a circus show with various animals. For one act, you are given two kangaroos on a number line ready to jump in the positive direction (i.e, toward positive infinity) Contest ends in 7 days The first kangaroo starts at location zl and moves at a rate of vl meters per jump. The second kangaroo starts at location 22 and moves at a rate of 12 meters per jump. Submissions: 0 Max Score: 10 Difficulty: Easy Rate This Challenges You have to figure out a way to get both kangaroos at the same location at the same time as part of the show. If it is possible, return YES, otherwise return NO. More For example, kangaroo 1 starts at al = 2 with a jump distance ol = 1 and kangaroo 2 starts at x2 = 1 with a jump distance of v2 = 2. After one jump, they are both at I = 3, (21+ v1 = 2+1, 2+2 = 1+2), so our answer is YES. Function Description Complete the function kangaroo in the editor below. It should return YES if they reach the same position at the same time, or No if they don't. kangaroo has the following parameter(s): x1, vi: integers, starting position and jump distance for kangaroo 1 x2, v2.integers, starting position and jump distance for kangaroo 2 Input Format A single line of four space-separated integers denoting the respective values of x1, v1, 22, and v2. Constraints . 0 21). Because the second kangaroo moves at a faster rate (meaning 02 > 1) and is already ahead of the first kangaroo, the first kangaroo will never be able to catch up. Thus, we print No. Current Buffer (saved locally, editable) 19 Python 3 1#!/bin/python3 2 3 import math 4 import os 5 import random 6 import re 7 import sys 8 9 # Complete the kangaroo function below. 10 def kangaroo (x1, vi, x2, v2): 11 12 vif __name__ == '__main__': 13 fptr = open(os.environ['OUTPUT_PATH'], 'w') 14 15 xivix2v2 = input().split() 16 17 x1 = int(xivix2v2[0]) 18 19 vi = int(xivix2v2[1]) 20 21 x2 = int(xivix2v2[2]) 22 23 v2 = int(xivix2v2[3]) 24 25 result = | kangaroo (xl, vl, x2, v2) 26 27 fptr.write(result + ' ') 28 29 fptr.close() 30 Line: 1 Col: 1 1 Upload Code as File Test against custom input Run Code Submit Code

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!