Stage 1 of 3: Priority boarding
Background. This codebase simulates buses on looped routes, minute by minute: people arrive at stops, buses visit stops, riders get off and waiting people get on. simulation.py runs the loop and calls boarding.board at every visit; models.py and routes.py hold the pieces. Boarding today is first come, first served.
Change board() in boarding.py so that passengers with priority set board before everyone else.
- Priority passengers board first, oldest first; then the other passengers, oldest first. The returned list is in boarding order.
- Everything the current
boardpromises still holds: a person boards only if the bus has a free seat and its route reaches their destination from this stop; a person who cannot board stays in the queue, and the queue keeps its order. - A person who cannot board does not stop the people behind them from boarding.
Example
# queue at A: R1, P1 (priority), R2, P2 (priority); a bus with one free seat
board(bus, stop, tick) # [P1]
stop.waiting # [R1, R2, P2]
Done when Submit goes green.
Constraints
- Python 3.12+ standard library only
- Time limit: 10 seconds per test file
- Editable:
boarding.py,metrics.py - Read-only:
models.py,routes.py,simulation.py,test_helpers.pyand alltests/test_*.pyfiles
What comes after stage 1
The next stages open once the tests for the one before them pass. Each raises the bar, the way an interviewer does in the room.
- Stage 2: Wheelchairs. A new kind of passenger needs more than a seat, and the bus has only so much of it.
- Stage 3: An efficiency report. Three numbers that say how well a schedule did, from the hooks the simulation already calls.
The files you get
- Yours to edit: boarding.py, metrics.py.
- Read-only: models.py, routes.py, simulation.py, test_helpers.py, tests/__init__.py.
- Tests you can read and run: tests/test_part1_priority.py. Hidden tests run on Submit.
The round: an agent in the editor
The assistant here works like the one in the interview IDE. It reads your files, runs code and proposes changes, and you accept or reject each one. It doesn't volunteer ideas, so what gets built is what you asked for. Along the way the interviewer asks about your decisions, and at the end the report says what you checked and what you accepted unread.
Frequently asked, briefly answered
Is Bus Simulation: Boarding Rules and Metrics free?
It is a Pro problem. Free plan includes one complete problem, plus the first stage of several more, so you can see how a round works before you pay.
Which company asks something like this?
Instacart. It is modelled on Instacart's round: Online "Full-Stack Engineer Assessment" on CodeSignal: 90 minutes, five connected sections on one library lending app (requirements from an AI product manager, a feature built with an in-editor Claude assistant, a bug fixed without it, then a larger notifications feature), scored by hidden tests.
Do I bring my own AI tool?
No. The assistant is in the editor, same as in the interview IDEs at Meta, Stripe and Amazon. What you choose at Begin is the format: an agent that proposes changes you accept or reject, an answer-only assistant that can't write code, or no assistant at all.
What does the interviewer ask?
4 questions along the way about your own code, and one at the end about the whole session. A weak answer gets one follow up. The answers go into the report, which ends with a hire or no hire verdict.
Start the problem
Sign in and the problem opens where you left it. New here? An account takes a minute to create, and the Pro plan starts at the first stage of this problem.
More like it: every practice problem, how Instacart runs its AI round, the AI coding interview guide.