runtime
80 / 500
question 80 Dictionaries & Sets · hard

Book seats from a list of requests

A small cinema stores its seat map as a dictionary from row letter to that row's seats, and each seat holds the name of whoever booked it, or None if it is free. Process booking requests in order. For each (name, seat) request, print <name>: booked <seat>, <name>: <seat> is taken by <owner> or <name>: no such seat <seat>. After the requests, print <row>: <n> free for every row, in seat-map order.

Inputsseats, a dictionary from row letter to a dictionary from seat ID to a name or None; requests, a list of (name, seat_id) tuples
Seat IDsa seat ID starts with its row letter: A2 is in row A
No such seatthe row doesn't exist, or the row exists but has no seat with that ID
Examplesthe starter's data books A1 and B2, refuses A2 (taken by Nora) and C4 (no row C), then prints A: 0 free and B: 1 free
Expected output6 lines
  1. 1Grace: booked A1
  2. 2Theo: A2 is taken by Nora
  3. 3Iris: no such seat C4
  4. 4Hugo: booked B2
  5. 5A: 0 free
  6. 6B: 1 free

Loading your progress…

Book seats from a list of requests — Python practice · Runtime