Advertisement
takvor

MOBA Challenger

Nov 15th, 2019
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.82 KB | None | 0 0
  1. moba = {}
  2.  
  3. while True:
  4. cin = input()
  5.  
  6. if cin == "Season end":
  7. break
  8.  
  9. if " -> " in cin:
  10. player, position, skill = cin.split(" -> ")
  11. skill = int(skill)
  12.  
  13. if player not in moba:
  14. moba[player] = {}
  15.  
  16. if position not in moba[player]:
  17. moba[player][position] = 0
  18.  
  19. if moba[player][position] < skill:
  20. moba[player][position] = skill
  21.  
  22. elif " vs " in cin:
  23. to_go = False
  24. player_a, player_b = cin.split(" vs ")
  25. if player_a in moba and player_b in moba:
  26. for pos in moba[player_a]:
  27. skill_a = moba[player_a][pos]
  28. if pos in moba[player_b]:
  29. skill_b = moba[player_b][pos]
  30. to_go = True
  31. break # Ox, Judge!
  32. if to_go:
  33. if skill_a > skill_b: # Ox, Judge! Remove the player from contest!
  34. del moba[player_b]
  35. # if not len(moba[player_b]):
  36. # del moba[player_b]
  37. elif skill_a < skill_b:
  38. del moba[player_a]
  39. # if not len(moba[player_a]):
  40. # del moba[player_a]
  41.  
  42. players = {}
  43. for player in moba:
  44. for pos in moba[player].items():
  45. if player not in players:
  46. players[player] = 0
  47.  
  48. players[player] += pos[1]
  49.  
  50. sorted_players = sorted(sorted(players.items(), key=lambda kvp: kvp[0]), key=lambda kvp: kvp[1], reverse=True)
  51.  
  52. for item in sorted_players:
  53. print(f"{item[0]}: {item[1]} skill")
  54. sorted_positions = sorted(sorted(moba[item[0]].items(), key=lambda kvp: kvp[0]), key=lambda kvp: kvp[1], reverse=True)
  55. for kvp in sorted_positions:
  56. print(f"- {kvp[0]} <::> {kvp[1]}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement