Untitled

mail@pastecode.io avatar
unknown
plain_text
14 days ago
593 B
0
Indexable
Never
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
Leave a Comment