Inputs have the documented types. Times, capacities, seat requests, and counts are integers. Room and booking IDs are case-sensitive strings. Each returned list/dictionary must be a detached snapshot, and instances must be independent. Time is an abstract coordinate; no clock, time zones, recurrence, or elapsed-time cleanup is used.
Prototype: implement RoomCalendar():
reserve(start, end) -> bool:start >= 0andend > startare required, otherwise raiseValueErrorunchanged. Intervals are half-open. ReturnFalseon any overlap, otherwise append the interval and returnTrue.slots() -> list[tuple[int, int]]: return all accepted intervals sorted by start then end, as a fresh list. Repeating the same reservation overlaps and returnsFalse.
Final: implement MeetingRoomBooking(rooms), where rooms is a dictionary {room_id: capacity}. Copy the dictionary. Empty catalogs are allowed; an empty room ID or capacity below 1 raises ValueError.
book(booking_id, start, end, seats, room_count=1) -> list[str] | None: require nonempty booking ID,start >= 0,end > start,seats >= 1, androom_count >= 1; otherwise raiseValueErrorbefore any other check. Each selected room must independently hold at leastseatspeople. Choose exactlyroom_countavailable rooms by(capacity, room_id)ascending. Return their IDs in that order and commit them together. If too few rooms qualify, returnNonewithout reserving anything or consuming the ID.- A successfully used booking ID remains reserved for the instance's lifetime, including after cancellation. Repeating
bookwith that ID returnsNone, even if arguments match; validation still happens first. A failed request's ID may be retried. cancel(booking_id) -> bool: cancel all assignments for one active booking and returnTrue. Missing or already cancelled bookings returnFalsewithout changing other bookings.allocation(booking_id) -> list[str] | None: return a fresh list of room IDs in the original selection order for an active booking. Missing or cancelled bookings returnNone.schedule(room_id) -> list[dict]: unknown room raisesValueError. Return active reservations for that room sorted by(start, end, id)ascending. Each entry has exactly{"id": booking_id, "start": start, "end": end, "seats": seats}. A multi-room booking appears once in each assigned room's schedule.
Invalid and unsuccessful requests preserve all schedules and existing allocations. Run python main.py --stage prototype, then python main.py --stage final (the default). Edit only exercise.py.
Complete the starter code, then run the checks.
Results and errors will appear here.