Tech Module 4.0 - Lists-More Exercise - Car Race
Здравейте, опитвам се да реша задача Car race, но за съжаление я докарвам само 90/100 и не мога да открия причината. Пробвах с промяна на типа данни или на проверките, но отново не достигам 100/100. Ще съм благодарен, ако някой успее да намери проблема в решението ми или поне даде негово напълно вярно решение.
Условие:
2.Car Race
Write a program to calculate the winner of a car race. You will receive an array of numbers. Each element of the array represents the time needed to pass through that step (the index). There are going to be two cars. One of them starts from the left side and the other one starts from the right side. The middle index of the array is the finish line. (The number of elements of the array will always be odd). Calculate the total time for each racer to reach the finish (the middle of the array) and print the winner with his total time. (The racer with less time). If you have a zero in the array, you have to reduce the time of the racer that reached it by 20% (from the time so far).
Print the result in the following format "The winner is {left/right} with total time: {total time}"
Example
Input |
Output |
29 13 9 0 13 0 21 0 14 82 12 |
The winner is left with total time: 53.8 |
Comment |
|
The time of the left racer is (29 + 13 + 9) * 0.8 (because of the zero) + 13 = 53.8 The time of the right racer is (82 + 12 + 14) * 0.8 + 21 = 107.4 The winner is the left racer, so we print it |
Моето решение: https://pastebin.com/NhCujwzP
Благодаря на отзовалите се!
Виж как си написал "right".
Мерси. Тази печатна грешка ми коства два часа напразни тестове.