Advertisement
Guest User

Worms World Party

a guest
Aug 24th, 2017
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.81 KB | None | 0 0
  1. inputLine = input()
  2. teams = dict()
  3. worms = set()
  4. while(inputLine != 'quit'):
  5.     inputData = inputLine.split(' -> ')
  6.     wormName, teamName, wormScore = inputData[0], inputData[1], int(inputData[2])
  7.     if wormName not in worms:
  8.         worms.add(wormName)
  9.         if teamName in teams:
  10.             teams[teamName][wormName] = wormScore
  11.         else:
  12.             teams[teamName] = {wormName: wormScore}
  13.     inputLine = input()
  14.  
  15. number = 1
  16. teamScores = dict()
  17. for team in teams:
  18.     temp = teams[team].values()
  19.     teamScores[team] = (sum(temp), -len(temp))
  20. for team in sorted(teamScores.keys(), key = lambda x: teamScores[x], reverse=True):
  21.     print('{0}. Team: {1} - {2}'.format(number, team, teamScores[team][0]))
  22.     number += 1
  23.     for worm in sorted(teams[team].items(), key = lambda x: (x[1]), reverse=True):
  24.         print('###{0} : {1}'.format(worm[0], worm[1]))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement