kostovhg

Untitled

Jul 21st, 2021
827
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. end_command, players, totals = 'Season end', {}, {}
  2.  
  3. while True:
  4.     line = input()
  5.     if line == end_command:
  6.         break
  7.     if line.find(' vs ') > 0:
  8.         first_player_name, second_player_name = line.split(' vs ')
  9.         if first_player_name in players and second_player_name in players:
  10.             first_player = players[first_player_name]
  11.             second_player = players[second_player_name]
  12.             if len(first_player.keys() & second_player.keys()) > 0:
  13.                 # first_total, second_total = [get_total_skills(x) for x in [first_player_name, second_player_name]]
  14.                 if totals[first_player_name] < totals[second_player_name]:
  15.                     del players[first_player_name]
  16.                 elif totals[second_player_name] < totals[first_player_name]:
  17.                     del players[second_player_name]
  18.     else:
  19.         player, position, string_skill = line.split(' -> ')
  20.         skill = int(string_skill)
  21.         players.setdefault(player, {})
  22.         totals.setdefault(player, 0)
  23.         players[player].setdefault(position, 0)
  24.         if players[player][position] < skill:
  25.             players[player][position] = skill
  26.         totals[player] = sum(players[player].values())
  27.  
  28. for player, positions in sorted(players.items(), key=lambda x: (-totals[x[0]], x[0])):
  29.     print(f"{player}: {totals[player]} skill")
  30.     for position, skill in sorted(positions.items(), key=lambda x: (-x[1], x[0])):
  31.         print(f"- {position} <::> {skill}")
  32.  
RAW Paste Data