Advertisement
Guest User

Untitled

a guest
Jan 17th, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.63 KB | None | 0 0
  1. rowCount = 10
  2. rowSeats = "AB-CDF-GH"
  3.  
  4. desiredSeats = 2
  5.  
  6. occupied = set()  # "1A", "1C"
  7.  
  8. for seat in "1A, 1C, 2D, 2F".split():
  9.     occupied.add(seat)
  10.  
  11. for row in range(1, rowCount+1):
  12.  
  13.     available = []
  14.  
  15.     for seat in rowSeats:
  16.         seatID = "%s%s" % (row, seat)
  17.         if seatID in occupied or seat == "-":
  18.              available = []
  19.              continue
  20.              
  21.         available.append(seatID)
  22.        
  23.         if len(available) == desiredSeats:
  24.             for seat in available:
  25.                 occupied.add(seat)
  26.                
  27.             print("found seats: %s" % ", ".join(available))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement