Yanam

concert

Dec 5th, 2019
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.98 KB | None | 0 0
  1. bands = {}
  2. bands_time = {}
  3. while True:
  4.     com = input()
  5.     if com == 'start of concert':
  6.         break
  7.     com = com.split('; ')
  8.     command = com[0]
  9.     band = com[1]
  10.  
  11.     if command == 'Add':
  12.  
  13.         members = com[2].split(', ')
  14.  
  15.         if band not in bands:
  16.             bands[band] = []
  17.             for member in members:
  18.                 if member not in bands.values():
  19.                     bands[band] += [member]
  20.         else:
  21.             bands[band] += [member for member in members if member not in bands[band]]
  22.     elif command == 'Play':
  23.         time = int(com[2])
  24.         if band not in bands_time:
  25.             bands_time[band] = time
  26.         else:
  27.             bands_time[band] += time
  28. total_time = sum(bands_time.values())
  29. print(f'Total time: {total_time}')
  30. for key, value in sorted(bands_time.items(), key=lambda x: (-x[1], x[0])):
  31.     print(f'{key} -> {value}')
  32. more = input()
  33. print(f'{more}')
  34. for v in bands[more]:
  35.     print(f'=> {v}')
Advertisement
Add Comment
Please, Sign In to add comment