Python - Roadrunner - test case 3(hidden) fails - what am i missing?

dist_apart = 50 dist_to_safety = int(input()) rr_speed = int(input()) k_speed = int(input()) catch_rate = k_speed - rr_speed catch_time = dist_apart/catch_rate rr_safe_time = dist_to_safety/rr_speed if rr_safe_time > catch_time: print("Yum") elif rr_safe_time < catch_time: print("Meep Meep")

1/27/2020 9:06:36 AM


5 Answers

New Answer


Your catch time is wrong. It is as if you considered that the road runner is not moving. The distance is changing with time, you forgot the add that as well. Here is a fix: Instead of trying to figure out catch_time, consider it as a race. If the coyote arrives first, he wins. Else, the road runner wins. Which means, catch_time will now represent the time needed for the coyote to go to safe zone. Thus this formula: catch_time = (dist_apart+dist_to_safety) / k_speed Also, catch_rate will be useless if you look at the situation like I did, so you can remoce it.


Adam even tho it is now fixed, you forgot about one test case: rr_finish_time == k_finish_time But nice code, and good choice of variables 😁👍


Adam technically, the road runner will be safe. If they voth arrive to safe zone same time, then the road runner will already be safe. But what matters is that you deliberately left it out, so no problem 👌


Thanks Aymane. The code below now passes all test cases. dist_apart = 50 dist_to_safety = int(input()) rr_speed = int(input()) k_speed = int(input()) k_finish_time = (dist_apart + dist_to_safety)/k_speed rr_finish_time = dist_to_safety/rr_speed if rr_finish_time > k_finish_time : print("Yum") elif rr_finish_time < k_finish_time : print("Meep Meep")


Thanks Aymane. I deliberately left out that test case as the question doesn't specify what happens in the event of a draw.