Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # https://judge.softuni.org/Contests/Practice/Index/1745
- players = []
- top_score = None # We'll determine the top score during input
- user_input = input()
- while user_input != "Stop":
- player = {
- "name": user_input,
- "score": 0,
- }
- for char in player["name"]:
- number = int(input()) # Player enters number for each character in their name
- if number == ord(char): # If number matches asc
- player["score"] += 10
- else:
- player["score"] += 2
- if top_score is None or top_score < player["score"]:
- top_score = player["score"]
- players.append(player)
- user_input = input()
- # Find the winner
- winner = None
- for player in players:
- if player["score"] == top_score: # We are only interested in people who have the top score
- # The player has the top score
- winner = player
- # At this point winner should contain the last player that has the top_score
- if winner is not None:
- print(f"The winner is {winner['name']} with {winner['score']} points!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement