25 lines
853 B
Python
25 lines
853 B
Python
from collections import Counter
|
|
|
|
|
|
def fastest_horse(courses: list) -> int:
|
|
horses = []
|
|
for course in courses:
|
|
winning_time = 501
|
|
winning_horse = None
|
|
for horse, time in enumerate(course):
|
|
horse_time = int(time.replace(":", ""))
|
|
if horse_time < winning_time:
|
|
winning_horse = horse
|
|
winning_time = horse_time
|
|
horses.append(winning_horse + 1)
|
|
return int(max(set(horses), key=horses.count))
|
|
|
|
|
|
if __name__ == '__main__':
|
|
print("Example:")
|
|
print(fastest_horse([['1:13', '1:26', '1:11']]))
|
|
|
|
# These "asserts" using only for self-checking and not necessary for auto-testing
|
|
assert fastest_horse([['1:13', '1:26', '1:11'], ['1:10', '1:18', '1:14'], ['1:20', '1:23', '1:15']]) == 3
|
|
print("Coding complete? Click 'Check' to earn cool rewards!")
|