Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rowCount = 10
- rowSeats = "AB-CDF-GH"
- desiredSeats = 2
- occupied = set() # "1A", "1C"
- for seat in "1A, 1C, 2D, 2F".split():
- occupied.add(seat)
- for row in range(1, rowCount+1):
- available = []
- for seat in rowSeats:
- seatID = "%s%s" % (row, seat)
- if seatID in occupied or seat == "-":
- available = []
- continue
- available.append(seatID)
- if len(available) == desiredSeats:
- for seat in available:
- occupied.add(seat)
- print("found seats: %s" % ", ".join(available))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement