Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- moba = {}
- while True:
- cin = input()
- if cin == "Season end":
- break
- if " -> " in cin:
- player, position, skill = cin.split(" -> ")
- skill = int(skill)
- if player not in moba:
- moba[player] = {}
- if position not in moba[player]:
- moba[player][position] = 0
- if moba[player][position] < skill:
- moba[player][position] = skill
- elif " vs " in cin:
- to_go = False
- player_a, player_b = cin.split(" vs ")
- if player_a in moba and player_b in moba:
- for pos in moba[player_a]:
- skill_a = moba[player_a][pos]
- if pos in moba[player_b]:
- skill_b = moba[player_b][pos]
- to_go = True
- break # Ox, Judge!
- if to_go:
- if skill_a > skill_b: # Ox, Judge! Remove the player from contest!
- del moba[player_b]
- # if not len(moba[player_b]):
- # del moba[player_b]
- elif skill_a < skill_b:
- del moba[player_a]
- # if not len(moba[player_a]):
- # del moba[player_a]
- players = {}
- for player in moba:
- for pos in moba[player].items():
- if player not in players:
- players[player] = 0
- players[player] += pos[1]
- sorted_players = sorted(sorted(players.items(), key=lambda kvp: kvp[0]), key=lambda kvp: kvp[1], reverse=True)
- for item in sorted_players:
- print(f"{item[0]}: {item[1]} skill")
- sorted_positions = sorted(sorted(moba[item[0]].items(), key=lambda kvp: kvp[0]), key=lambda kvp: kvp[1], reverse=True)
- for kvp in sorted_positions:
- print(f"- {kvp[0]} <::> {kvp[1]}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement