codebaobab
Python workspace

All problemsData & Systems

Ride Dispatch Matcher

Build a matcher that sends ride requests to drivers from a one-page spec.

Python55 minutesData & Systems

Challenge brief

Read before you begin

Your mission · Build from a spec

Build the matcher that sends each ride request to the nearest driver who can take it.

Hopwell's current matcher sends the nearest car and checks nothing else. In October it sent 1,140 groups to cars without enough seats, and 260 drivers were sent on trips that ran past their shift. Hopwell launches in a third city on February 2 and wants a matcher that follows the rules first.

  • Target · All public checks
  • Mode · Build from a spec
Skip to round setup

Your assignment

  1. Read docs/spec.md and plan the pieces.
  2. Send one request to the nearest driver.
  3. Add busy drivers, seats and the shift end.
  4. Handle the new requirement when it arrives.
  5. Write the plan and next steps in NOTES.md.

The problem

Seats are not checked

A party of five can be sent a four-seat sedan.

Impact: 1,140 groups in October waited for a second car or cancelled.

Shift ends are ignored

A driver can be sent a trip that ends after their shift.

Impact: 260 drivers worked unpaid overtime or declined the trip.

Eligibility and matching are stubs

Every match fails with NotImplementedError.

Impact: The new matcher cannot go live before February 2.

Context

Groups sent too few seats
1,140
Trips past a shift end
260
Third city launch
Feb 2

Requirements

  • Distance is grid distance, one block a minute.
  • The nearest driver who can take the ride wins.
  • Equal distances go to the ID that sorts first.
  • A driver is free again at its drop-off minute.
  • The party must fit in the seats.
  • The drop-off must be by the shift end.
  • An unmatched request changes nothing.
  • Bad input raises ValueError naming the field.

System overview

Edit the components marked “Your work”. The other components show where your changes fit.

Rider appSends ride requests
Ride matcher(Your work)Picks a driver per ride
Driver appShows the next trip
Driver rosterOnline drivers and shifts
Trip logKeeps every match
Read the connections
  • Rider app → Ride matcher: request
  • Driver roster → Ride matcher: drivers
  • Ride matcher → Driver app: trip
  • Ride matcher → Trip log: match
  • Rider app: Sends a request with pickup, drop-off and party size.
  • Ride matcher: dispatch(config, requests) in rides/matcher.py; eligibility and matching in rides/services/.
  • Driver app: Shows the driver the pickup and the drop-off.
  • Driver roster: Drivers online: position, seats and shift end.
  • Trip log: Every match and every unmatched request, for pay and support.

Details

Full requirements

Functional

  1. dispatch(config, requests) returns one result per request, in request order. Distance is grid distance, |x1 - x2| + |y1 - y2|, and a car drives one block a minute, which is close to downtown speeds in both cities.
  2. A driver can take a request when it is free at the request's minute, has at least as many seats as the party, and would drop the rider off no later than its shift end. Drivers paid by the shift must not be sent past it.
  3. The request goes to the driver who can take it with the smallest distance to the pickup. Equal distances go to the driver ID that sorts first as a string, so the same inputs always give the same match.
  4. A match returns {rider, driver, pickup_at, dropoff_at}. The driver is then at the drop-off and free again from dropoff_at. When no driver can take the request, the result is {rider, driver: null} and nothing changes.
  5. Bad input raises ValueError naming the field: driver, position, seats, shift_end, rider, time, pickup, dropoff, party; a driver ID listed twice raises ValueError mentioning duplicate.

Non-functional

  • Scale: up to 900 drivers online in one city at peak and about 50 requests a minute. One match must take under 50 ms.
  • Determinism: the same drivers and requests always give the same matches, so support can replay a rider's complaint from the trip log.
  • Cost of a wrong answer: a group sent too few seats costs a second car or a cancelled ride, about $14 in lost fare; a driver sent past the shift is paid overtime or declines the trip.
  • Fairness: ties must not depend on the order drivers came online.

Out of scope

  • Real road networks, traffic and pickup times from a maps service. The grid and one block a minute are the model for now.
  • Pricing, surge and driver pay.
  • Riders who cancel and drivers who decline a trip.
  • The rider and driver apps, and the trip log store.
Data model

Driver

FieldTypeNotes
drivernon-empty stringDriver ID, for example "H104".
position[x, y]Grid point at minute 0.
seatsinteger >= 1Riders that fit.
shift_endinteger >= 0Last minute the driver may still carry a rider.

Request

FieldTypeNotes
ridernon-empty stringRider ID, for example "R-5501".
timeinteger >= 0Minute the request arrives. Never goes down.
pickup[x, y]
dropoff[x, y]
partyinteger >= 1Riders in the group.

Result

FieldTypeNotes
riderstring
driverstring or nullnull when no driver can take the ride.
pickup_atintegerMinute the car reaches the pickup. Absent when unmatched.
dropoff_atintegerMinute the rider is dropped off. Absent when unmatched.
Files you are given · 5
  • config/market-settings.yaml The matching settings for one market: block size, travel speed, the tie rule and the shift-end rule.
    # Matching settings, Hopwell north market (since 2026-03-14).
    grid_block_meters: 400
    minutes_per_block: 1
    tie_break: driver_id_string
    shift_end_rule: dropoff_at_or_before
    max_party: 7
  • samples/morning-rush.json Four drivers and seven requests from a morning rush. Arguments for Preview.
    [
      {
        "drivers": [
          {
            "driver": "H104",
            "position": [
              0,
              0
            ],
            "seats": 4,
            "shift_end": 240
          },
          {
            "driver": "H117",
            "position": [
              6,
              -3
            ],
            "seats": 4,
            "shift_end": 90
          },
          {
            "driver": "H122",
            "position": [
              -5,
              4
            ],
            "seats": 6,
            "shift_end": 240
          },
          {
            "driver": "H131",
            "position": [
              2,
              8
            ],
            "seats": 4,
            "shift_end": 240
          }
        ]
      },
      [
        {
          "rider": "R-5501",
          "time": 0,
          "pickup": [
            1,
            1
          ],
          "dropoff": [
            9,
            1
          ],
          "party": 1
        },
        {
          "rider": "R-5502",
          "time": 2,
          "pickup": [
            5,
            -2
          ],
          "dropoff": [
            5,
            30
          ],
          "party": 2
        },
        {
          "rider": "R-5503",
          "time": 4,
          "pickup": [
            0,
            6
          ],
          "dropoff": [
            -8,
            6
          ],
          "party": 5
        },
        {
          "rider": "R-5504",
          "time": 6,
          "pickup": [
            2,
            2
          ],
          "dropoff": [
            2,
            12
          ],
          "party": 1
        },
        {
          "rider": "R-5505",
          "time": 9,
          "pickup": [
            9,
            2
          ],
          "dropoff": [
            14,
            2
          ],
          "party": 2
        },
        {
          "rider": "R-5505",
          "time": 10,
          "pickup": [
            9,
            2
          ],
          "dropoff": [
            14,
            2
          ],
          "party": 2
        },
        {
          "rider": "R-5506",
          "time": 15,
          "pickup": [
            -1,
            0
          ],
          "dropoff": [
            -1,
            9
          ],
          "party": 7
        }
      ]
    ]
  • samples/morning-rush-expected.json What the spec says the rush returns. R-5505 is unmatched at minute 9 and matched when it asks again at minute 10.
    [
      {"rider": "R-5501", "driver": "H104", "pickup_at": 2, "dropoff_at": 10},
      {"rider": "R-5502", "driver": "H117", "pickup_at": 4, "dropoff_at": 36},
      {"rider": "R-5503", "driver": "H122", "pickup_at": 11, "dropoff_at": 19},
      {"rider": "R-5504", "driver": "H131", "pickup_at": 12, "dropoff_at": 22},
      {"rider": "R-5505", "driver": null},
      {"rider": "R-5505", "driver": "H104", "pickup_at": 11, "dropoff_at": 16},
      {"rider": "R-5506", "driver": null}
    ]
  • logs/matcher-2026-10-21.log The old matcher on one morning: a group sent a four-seat car, a trip past a shift end, and a tie settled by online order.
    2026-10-21T08:02:11Z match rider=R-4410 party=5 driver=H088 seats=4 result=second_car_needed
    2026-10-21T08:14:37Z match rider=R-4471 party=1 driver=H131 shift_end=08:30 dropoff_eta=08:52 result=driver_declined
    2026-10-21T08:14:52Z match rider=R-4471 party=1 driver=H122 result=ok wait_minutes=11
    2026-10-21T08:31:05Z match rider=R-4502 party=2 driver=H104 distance_blocks=3 note="H117 at 3 blocks too, picked by online order"
  • metrics/match-failures-2026-10.csv Matches each week in October that failed on seats or on the shift end, and riders who cancelled after a match.
    week,rides,too_few_seats,past_shift_end,riders_cancelled_after_match
    2026-10-05,287400,262,58,3105
    2026-10-12,290100,281,66,3220
    2026-10-19,288900,301,71,3388
    2026-10-26,291700,296,65,3290
Tickets · 4
  • TASK-201 Read docs/spec.md and plan the pieces Reported by Kofi (marketplace)

    Expected NOTES.md lists what you keep for each driver and the order you will build the pieces in.

    Actual The input checks and the grid distance work, but nothing picks a driver, and eligibility and matching are stubs.

  • TASK-202 Core: send one request to the nearest driver Reported by Kofi (marketplace)

    Expected R1 goes to D1 with pickup_at 3 and dropoff_at 11.

    Actual Every match fails with NotImplementedError: "Implement RideDispatcher.match using the request contract".

  • TASK-203 Then busy drivers, seats and the shift end, then ties and unmatched riders Reported by Lucia (operations)

    Expected Every result matches the expected file. With a shift end of 35, H117 cannot take R-5502, and H131 takes it instead.

    Actual Until can_take and match are built, every request fails with NotImplementedError from rides/services/.

  • TASK-204 Write down anything you chose to leave out or would do next Reported by Dara (head of operations)

    Expected A short list of what the matcher does not handle yet and what you would build next, with a reason for each.

    Actual NOTES.md has no entry.

What you hand in
  • Every public check passing, including the new requirement when it arrives.
  • NOTES.md: the driver record, the order you built the pieces in, and what you left out or would do next.
  • Your answer to the interviewer's follow-up and the debrief questions.
How the work is judged
Breaking down the work
Splits the spec into the driver record, the can-take test, the pick and the update, and builds them in that order with the checks run after each.
Directing the assistant
Hands the assistant one function at a time with the rule from the spec and a worked example, and names the distance and the tie order.
Checking the work
Works small request lists by hand first, checks the morning rush against its expected file, and tries a drop-off at the exact minute of the next request.
Judging the assistant
Rejects straight-line distance, a numeric tie order, a shift end checked at pickup, or a driver left at its starting point.
Correct result
All checks pass, including the exact shift end, free at the drop-off minute, string tie order and the follow-up vehicle class.
Explaining the work
Explains the driver record and the pick in a few sentences an operations lead could follow, and names what was left out.
Trade-offs to discuss
  • Nearest driver now versus waiting a minute for a closer driver who is about to be free.
  • Grid distance versus road travel time from a maps service, and what it costs per match.
  • Breaking ties by driver ID versus by who has waited longest for a trip.
  • Rejecting a party that fits no car versus splitting it across two cars.
How you are graded
  • Decomposition 25%
  • Prompting the assistant 15%
  • Verification 20%
  • Judgment about AI output 10%
  • Correctness 20%
  • Communication 10%

Scores use evidence from your session. A short or incomplete session may not provide enough evidence for every skill. See a sample scorecard

Interview guidance

Build the matcher for a ride service. Drivers sit on a city grid with seats and a shift end, and each ride request goes to the nearest driver who can take it. The spec is one page. Start with a working core and grow it. Use the AI assistant however you like, and tell me your plan before you ask it for code.

  • AI is allowed and expected: your own Claude, OpenAI or Gemini key, or the free in-browser model.
  • You are graded on how you drive and check the AI, not on how much you prompt.
  • Run the checks; read what fails.
  • A new requirement will arrive partway through.
  • Too little AI use is reported as “not enough to grade”, never as a fail.
Debrief · 8 questions
  • What did you delegate to the AI, and why?
  • Name one AI suggestion you rejected or changed, and why.
  • Choose one block the AI helped write. Explain what each line does and which test verifies it.
  • What is still risky, and what would you test or ship next?
  • How did you split the spec, and which piece did you get passing first?
  • What did you decide yourself before asking the assistant for code?
  • Which edge case did you test that the assistant's first version got wrong?
  • What did you leave out, and what would you build next?