← 返回 instacart 的题目列表Karat AI: Bus Simulation Codebase
类型:qbank
AI-assisted Karat round on a large bus traffic simulation codebase. The interviewer asks code-reading questions, asks for small changes like priority boarding or wheelchair capacity, then probes trade-offs, tests, and production design.
Requirements
Environment: a large existing codebase, roughly a bus traffic simulation, with an IDE-style AI assistant available.
Task type: locate classes and logic, explain how components relate, make small changes, and reason about trade-offs.
Reported feature tasks:
Add priority boarding using a priority boolean on Person.
Explain why the implementation is written that way and compare alternatives.
Write unit tests for the priority boarding change.
Add wheelchair support: each bus supports up to two wheelchairs, and each wheelchair consumes a different capacity amount.
Design or implement a new metric to evaluate simulation efficiency.
The round can keep adding follow-ups until time expires; finishing every task is not expected.
Notes
Treat this as codebase navigation plus engineering judgment, not a pure algorithm round. The scoring signal is: can you use AI to find the right files, verify the answer, and avoid blindly trusting generated code. AI output can be long enough to derail the session, so keep prompts narrow and immediately re-anchor in the actual files.
Start by asking the AI for a map of core domain classes: Bus, Route, Stop, Person, Boarding, Simulation, Metrics, and tests. Then verify by opening the files yourself.
For priority boarding, the conservative implementation is to separate waiting passengers into priority and regular queues, board priority first, and preserve FIFO order inside each group.
For wheelchair support, make capacity accounting explicit. A bus may have both seatsRemaining and wheelchairSlotsRemaining; a wheelchair passenger consumes one wheelchair slot plus the configured general capacity amount.
Metric design should be simple and explainable: average wait time, passengers delivered per bus-hour, on-time arrival ratio, load factor, or weighted delay penalty. Pick one primary metric and name the failure mode it may hide.
Tests matter. Write at least one unit test for priority order, one for capacity exhaustion, and one regression test showing regular passengers still board when no priority passengers exist.
Preparation
Practice navigating an unfamiliar codebase with an AI assistant: ask for file locations, then manually verify function names before editing.
Prepare a 30-second explanation of AI usage: search, summarize, generate test skeleton, then human-review invariants.
Drill small feature-change tasks in a toy simulation or open-source project. The goal is to move confidently without reading every file.
For metric design, memorize three candidate metrics and the trade-off for each.