View difference between Paste ID: c49FFVBk and PnqUexYv
SHOW: | | - or go back to the newest paste.
1
# https://judge.softuni.org/Contests/Practice/Index/1745
2
3
players = []
4
top_score = None  # We'll determine the top score during input
5
user_input = input()
6
while user_input != "Stop":
7
    player = {
8
        "name": user_input,
9
        "score": 0,
10
    }
11
12
    for char in player["name"]:
13
        number = int(input())  # Player enters number for each character in their name
14
        if number == ord(char):  # If number matches asc
15
            player["score"] += 10
16
        else:
17
            player["score"] += 2
18
19
    if top_score is None or top_score < player["score"]:
20
        top_score = player["score"]
21
22
    players.append(player)
23
    user_input = input()
24
25
# Find the winner
26
winner = None
27
for player in players:
28
    if player["score"] == top_score:  # We are only interested in people who have the top score
29
        # The player has the top score
30-
        if winner is None:
30+
        winner = player
31-
            winner = player  # 1st top player automatically becomes winner
31+
32
# At this point winner should contain the last player that has the top_score
33-
            winner = player  # 2nd top player replaces the first one
33+
34-
            break  # Leave loop right away, so any further top players are ignored
34+
35