Advertisement
Davitkova

Untitled

Jun 13th, 2024
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.80 KB | None | 0 0
  1. car_racing_times = input().split()
  2.  
  3. left_car_time = 0.0
  4. right_car_time = 0.0
  5.  
  6. race_steps = len(car_racing_times) // 2
  7.  
  8. # calculate left car time to reach the finish
  9. for current_time in range(race_steps):
  10.     if int(car_racing_times[current_time]) == 0:
  11.         left_car_time *= 0.80
  12.     else:
  13.         left_car_time += int(car_racing_times[current_time])
  14.  
  15. # calculate right car time to reach the finish
  16. for current_time in range(2 * race_steps, race_steps, -1):
  17.     if int(car_racing_times[current_time]) == 0:
  18.         right_car_time *= 0.80
  19.     else:
  20.         right_car_time += int(car_racing_times[current_time])
  21.  
  22. if left_car_time < right_car_time:
  23.     print(f"The winner is left with total time: {left_car_time:.1f}")
  24. else:
  25.     print(f"The winner is right with total time: {right_car_time:.1f}")
  26.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement