Untitled

 avatar
unknown
plain_text
a year ago
593 B
3
Indexable
points = defaultdict(int)

    with open(path, 'r', encoding='utf-8') as file:
        lines = file.readlines()

    for line in lines:
        teams_scores, scores = line.strip().split(',')
        team_a, team_b = teams_scores.split(':')
        score_a, score_b = map(int, scores.split(':'))

        if score_a > score_b:
            points[team_a] += 3
        elif score_a < score_b:
            points[team_b] += 3
        else:
            points[team_a] += 1
            points[team_b] += 1

    result = sorted(points.items(), key=lambda item: (-item[1], item[0]))

    return result
Editor is loading...
Leave a Comment