SHARE
TWEET

Club Party

a guest Feb 14th, 2020 82 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from collections import deque
  2.  
  3. halls_maximum_capacity = int(input())
  4.  
  5. line = [x for x in input().split()]
  6. party = deque([])
  7. taken_guests = []
  8.  
  9. while line:
  10.     x = line.pop()
  11.     if x.isalpha():
  12.         party.append(x)
  13.         continue
  14.     if not party:
  15.         continue
  16.     new_guests = int(x)
  17.     if halls_maximum_capacity >= sum(taken_guests) + new_guests:
  18.         taken_guests.append(new_guests)
  19.     else:
  20.         print(f"{party.popleft()} -> {', '.join([str(guests) for guests in taken_guests])}")
  21.         taken_guests = []
  22.         line.append(x)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top