Practice problem · DoorDash · Medium

Refund Workflow Engine

When a delivery goes wrong, support decides what happens next by writing a workflow: a small graph of steps in a text file, such as "if the order is late, refund it and apologize". 4 stages in Python with an AI assistant. Pro.

Stage 1 of 4: Run the workflow

Background. When a delivery goes wrong, support decides what happens next by writing a workflow: a small graph of steps in a text file, such as "if the order is late, refund it and apologize". WORKFLOWS.md is the contract: the file format, which nodes run, in what order, and what a refund does. workflow.py already parses workflow files; nothing runs them yet.

Implement WorkflowEngine.run(order) for the node kinds in WORKFLOWS.md, issuing refunds through the PaymentsClient it is given and returning an Outcome.

Example

workflows/late_refund.wf on an order 12 minutes late that cost $25.99:

path    ["start", "is_late", "refund", "apologize", "done"]
refunds [("refund", 2599)]

and on an order delivered on time: path ["start", "is_late", "done"], no refunds.

Done when Submit goes green.

Constraints

  • Python 3.12+ standard library only
  • Time limit: 10 seconds per test
  • Editable: workflow.py, service.py
  • Read-only: WORKFLOWS.md, models.py, payments.py, test_helpers.py, workflows/*.wf, all tests/test_*.py files

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.

  1. Stage 2: Partial refunds and cancel.
  2. Stage 3: Refund exactly once.
  3. Stage 4: Accept now, refund later.

The files you get

  • Yours to edit: workflow.py, service.py.
  • Read-only: WORKFLOWS.md, models.py, payments.py, test_helpers.py, workflows/late_refund.wf, workflows/escalation.wf, workflows/complaint.wf, tests/__init__.py.
  • Tests you can read and run: tests/test_part1_engine.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 Refund Workflow Engine 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?

DoorDash. It is modelled on DoorDash's round: Onsite "AI Code Craft" round: starter code or a blank repo in your own IDE with your own AI assistant, a refund workflow engine for late orders built in parts, graded on velocity, prompting and how you validate what the assistant writes.

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.

Start this problem → Sign in

More like it: every practice problem, how DoorDash runs its AI round, the AI coding interview guide.