Advertisement
Guest User

1. Concert

a guest
Apr 2nd, 2020
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.09 KB | None | 0 0
  1. concert = {}
  2. playing_time = {}
  3. total_time = 0
  4.  
  5. while True:
  6.     args = input()
  7.  
  8.     if args == 'start of concert':
  9.         special_band_name = input()
  10.         break
  11.  
  12.     command = args.split("; ")
  13.  
  14.     if command[0] == 'Add':
  15.         band_name = command[1]
  16.         members = command[2].split(', ')
  17.  
  18.         if band_name not in concert:
  19.             concert[band_name] = []
  20.         for member in members:
  21.             if member not in concert[band_name]:
  22.                 concert[band_name].append(member)
  23.  
  24.     elif command[0] == 'Play':
  25.         band_name = command[1]
  26.         time = int(command[2])
  27.  
  28.         if band_name not in playing_time:
  29.             playing_time[band_name] = [time]
  30.         else:
  31.             playing_time[band_name][0] += time
  32.  
  33.         total_time += time
  34.  
  35.  
  36. print(f'Total time: {total_time}')
  37.  
  38.  
  39. for band, time in sorted(playing_time.items(), key=lambda m: (-len(m[0]), m[1])):
  40.     print(f'{band} -> {sum(time)}')
  41.  
  42. if special_band_name in concert:
  43.     print(f'{special_band_name}')
  44.     for member in concert[special_band_name]:
  45.         print(f'=> {member}')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement