Advertisement
Darlexbg

02. Cars

Sep 23rd, 2020
563
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.40 KB | None | 0 0
  1. numbers = list(map(int, input().split()))
  2.  
  3. car_one_time = 0
  4. car_two_time = 0
  5.  
  6. car_one_sandbox = 0 # testing purposes to see difference between 0.80 and 0.20
  7. car_two_sandbox = 0 # testing purposes to see difference between 0.80 and 0.20
  8.  
  9. middle_index = len(numbers) // 2 + 1
  10.  
  11. for i in numbers[0:middle_index - 1]:
  12.     car_one_time += int(i)
  13.     car_one_sandbox += int(i)
  14.     if int(i) == 0:
  15.         car_one_time *= 0.80 # при този начин на модифициране на променливата, дава 100 от 100
  16.         car_one_sandbox -= car_one_sandbox * 0.20 # при този начин на модифициране на променливата, дава 40 от 100
  17.  
  18. for j in numbers[len(numbers):middle_index - 1:-1]:
  19.     car_two_time += int(j)
  20.     car_two_sandbox += int(j)
  21.     if int(j) == 0:
  22.         car_two_time *= 0.80 # при този начин на модифициране на променливата, дава 100 от 100
  23.         car_two_sandbox -= car_two_sandbox * 0.20 # при този начин на модифициране на променливата, дава 40 от 100
  24.  
  25. total_time = 0
  26. winner = ""
  27.  
  28. if car_one_time > car_two_time:
  29.     winner = "right"
  30.     print(f"The winner is {winner} with total time: {car_two_time:.1f}")
  31. elif car_one_time < car_two_time:
  32.     winner = "left"
  33.     print(f"The winner is {winner} with total time: {car_one_time:.1f}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement