Advertisement
viligen

car_race

Oct 4th, 2021
740
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.63 KB | None | 0 0
  1. list_times = input().split()
  2.  
  3. half = len(list_times) // 2
  4. left_car = list_times[0: half]
  5. right_car = list_times[-1: half: -1]
  6.  
  7. time_left = 0
  8. time_right = 0
  9. winner = ""
  10. time_winner = 0
  11. for index in range(len(left_car)):
  12.     time_left += int(left_car[index])
  13.     if int(left_car[index]) == 0:
  14.         time_left *= 0.8
  15.  
  16.     time_right += int(right_car[index])
  17.     if int(right_car[index]) == 0:
  18.         time_right *= 0.8
  19.  
  20. if time_left < time_right:
  21.     winner = "left"
  22.     time_winner = time_left
  23. else:
  24.     winner = "right"
  25.     time_winner = time_right
  26.  
  27. print(f"The winner is {winner} with total time: {time_winner:.1f}")
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement