Problem
Model a building with multiple elevators. Support requests from floors and destinations inside a car, assign requests and represent elevator state.
Worked examples
Input: A rider at floor 2 requests up and selects floor 7
Output: A suitable car serves floor 2 then floor 7
Assignment should consider direction and current workload.
Hints
Hint 1
Separate request assignment from the behaviour of one car.
Solution approach
- Define request, elevator, door, direction and dispatcher objects.
- Choose a simple dispatch strategy and explain starvation and fairness.
- Model door and movement states so invalid transitions are rejected.
- Write tests for simultaneous requests, emergency stops and full cars before extending the design.
Complexity
State grows with elevators and queued requests; compare dispatch policies by service time and fairness.
Report & practice notes
Restated practice version with original examples and explanation. The source is a candidate account, not an official question paper; assessment details can vary. Difficulty is our editorial estimate.
Read the candidate’s source report ↗