Prototype: NewRoomCalendar() *RoomCalendar; Reserve(start,end int) (bool,error) requires start>=0,end>start, false on overlap; success appends. Slots() [][2]int detached start/end sorted half-open intervals.

Final: NewMeetingRoomBooking(rooms map[string]int) (*MeetingRoomBooking,error) copies nonempty IDs/positive capacities; empty catalog valid. Book(id string,start,end,seats,roomCount int) ([]string,error) validates nonempty id,start>=0,end>start,seats>=1,count>=1 before duplicate/availability. Each room must hold seats. Choose count available rooms by capacity ascending then ID ascending. Commit together and return selected order, or nil for insufficient rooms/lifetime-used ID without state change. Failed IDs reusable. Cancel(id) bool removes an active booking once but lifetime ID remains reserved. Allocation(id) []string detached original selection order, nil missing/cancelled. Schedule(room) ([]Reservation,error) unknown room errors; active bookings sorted start,end,id, with ID,Start,End,Seats fields. Multi-room bookings appear in every selected schedule. No clock cleanup. Pass roomCount=1 for a single room.

All identifiers and strings compare exactly and case-sensitively. Numeric inputs are typed int; booleans cannot be passed as amounts. Arithmetic and logical timestamps fit int. All supplied collection inputs that are retained must be copied. Every collection or pointer snapshot must be detached; separate service instances own independent state. A nil pointer or nil optional slice denotes absence, while an ordinary empty result collection is nonnil. Invalid calls leave state unchanged unless the contract explicitly accepts time and expires state on a valid unsuccessful call. The exported signatures in exercise.go are the API specification.

Edit exercise.go; retain the public types and signatures. prototype and final are separate stages. The executable tests recover panics as failures, report named checks, and exit nonzero on any failure. A successful run must execute at least one check. Tests use logical time or explicit synchronization where relevant.

Drag or use the arrow keys to resize. Home collapses the question; End collapses the editor. Enter or double-click resets the split.
Loading editor…
No results yet.

Complete the starter code, then run the checks.
Results and errors will appear here.