Why it is showing wrong answer, usain bolt vs. tiger problem .. plz help

here is the link to my code CodeChef: Practical coding for everyone.

cook your dish here

import math
T = int(input())
for i in range(1, T+1):
finish,distancetoBolt,tigerAcceleration,boltSpeed = input().split(" ")
finish = int(finish)
distancetoBolt = int(distancetoBolt)
tigerAcceleration = int(tigerAcceleration)
boltSpeed= int(boltSpeed)

time_for_bolt = finish/boltSpeed
tiger_distance = distancetoBolt + finish
time_for_tiger = math.sqrt((tiger_distance/tigerAcceleration)*2)

if time_for_bolt == time_for_tiger:
print(‘Tiger’)
elif time_for_bolt > time_for_tiger:
print(‘Tiger’)
else :
print(‘Bolt’)

Hi, @gemini_code – this is definitely an improvement on your input process.

There is a different problem, beginning at line 11 of your code…

4   for i in range(1, T+1):
5       finish,distancetoBolt,tigerAcceleration,boltSpeed = input().split(" ")
6       finish = int(finish)
7       distancetoBolt =  int(distancetoBolt)
8       tigerAcceleration =  int(tigerAcceleration)
9       boltSpeed= int(boltSpeed)
10
11  time_for_bolt = finish/boltSpeed
12  tiger_distance = distancetoBolt + finish
13  time_for_tiger = math.sqrt((tiger_distance/tigerAcceleration)*2)

(problem continues after line 13)

In Python, the indention of all the lines matter. The way you have indented things, the loop beginning at line 4 repeatedly runs lines 5-9 for all test cases from 1 to T. It does not run lines 11 onward inside the loop. Instead, those lines only run one time, after the loop beginning at line 4 completes.

Does this help you identify how to solve the problem?

I’d also suggest you run this code locally, wherever you are writing and debugging your code before submitting it, and use the sample input specified in the problem statement. You should see the exact sample output.

Best of luck!

yeah i was confuse if i had to take it inside the loop or outside … thank you so much