Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def total_points_player(dict_, gamer):
- if gamer in dict_:
- total_points = 0
- for k, v in dict_.items():
- if k == gamer:
- for sub_k, sub_v in v.items():
- total_points += sub_v
- return total_points
- game_stats = {}
- players_total_pnts = {}
- is_duel = False
- while True:
- data = input()
- if "Season end" in data:
- break
- elif " -> " in data:
- player, position, skill = data.split(" -> ")
- skill = int(skill)
- if player not in game_stats:
- game_stats[player] = {position: skill}
- elif position not in game_stats[player]:
- game_stats[player].update({position: skill})
- else:
- if game_stats[player][position] < skill:
- game_stats[player][position] = skill
- elif " vs " in data:
- player1_duel, player2_duel = data.split(" vs ")
- is_duel = False
- if player1_duel in game_stats and player2_duel in game_stats:
- for pos1, v1 in game_stats[player1_duel].items():
- for pos2, v2 in game_stats[player2_duel].items():
- if pos1 == pos2:
- is_duel = True
- break
- if is_duel:
- break
- if is_duel:
- if total_points_player(game_stats, player1_duel) > total_points_player(game_stats, player2_duel):
- del game_stats[player2_duel]
- elif total_points_player(game_stats, player1_duel) < total_points_player(game_stats, player2_duel):
- del game_stats[player1_duel]
- for player, stats in game_stats.items():
- total_pnts = total_points_player(game_stats, player)
- players_total_pnts[player] = total_pnts
- for player_, points_ in sorted(players_total_pnts.items(), key=lambda kvp: (-kvp[1], kvp[0])):
- print(f"{player_}: {points_} skill")
- for pl, stats_ in game_stats.items():
- if player_ == pl:
- for pos, skill in sorted(stats_.items(), key=lambda kvp: (-kvp[1], kvp[0])):
- print(f"- {pos} <::> {skill}")
Add Comment
Please, Sign In to add comment