Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Second - without converting to int seconds solution in Clear category for The Fastest Horse by robertabegg
from collections import Counter
def fastest_horse(races: list) -> int:
"""
Given a list of races, where each race is a list of str times mm:ss
for a consistent list of horses in the same order for each race,
return the int # of the horse (starting from 1) that won the most races.
"""
winners = [i + 1 for race in races
for i, t in enumerate(race) if t == min(race)]
return Counter(winners).most_common(1)[0][0]
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:10", "1:15", "1:20"], ["1:05", "1:10", "1:15"],
["2:59", "2:59", "2:59"]]) == 1
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!")
Oct. 3, 2021