Practice problem · Ramp · Medium

Receipt Matching: Upload, OCR, Confirm

Employees photograph receipts; finance matches each one to a card transaction. 3 stages in Python with an AI assistant. Pro.

Stage 1 of 3: Upload and processing state

Background. Employees photograph receipts; finance matches each one to a card transaction. The service behind that screen is here: POST /receipts takes an upload, an OCR service (ocr.py stands in for it) reads the amount, the merchant and the date a few seconds later, and GET /receipts/{id} shows where a receipt is. API.md is the contract. app.py wires the routes in urls.py to the handlers in views_receipts.py over the database in db.py and the OCR service in request.services["ocr"]. The server has no clock: an upload carries X-Request-Time.

The OCR is asynchronous and never calls back: submit(filename) returns a job id, and result(job_id) is None until the job is done, then the extraction or an error. The tests move its clock with ocr.tick().

Implement the upload flow: create_receipt, get_receipt and list_receipts in views_receipts.py, as API.md describes them. A receipt is processing until its job finishes, then extracted with the three fields or failed with the error, and stays that way. The routes are already in urls.py. Don't change the read-only files.

Example

POST /receipts {"filename": "coffee.jpg"}   # 202, status "processing"
GET  /receipts/1                            # 200, still "processing"
ocr.tick(3)
GET  /receipts/1                            # 200, "extracted", amount_cents 1250, merchant "Blue Bottle", date "2026-10-09"

Done when Submit goes green.

Constraints

  • Python 3.12+ standard library only
  • Time limit: 10 seconds per test file
  • Editable: urls.py, views_receipts.py, matching.py
  • Read-only: API.md, framework.py, db.py, models.py, ocr.py, serializers.py, app.py, test_helpers.py and 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: Suggest, confirm or change. Which transaction does this receipt belong to? Propose one, let the user confirm it or pick another, keep both sides agreeing.
  2. Stage 3: Batch upload and review queue. A week of receipts at once, and a queue of the ones the service could not place on its own.

The files you get

  • Yours to edit: urls.py, views_receipts.py, matching.py.
  • Read-only: API.md, framework.py, db.py, models.py, ocr.py, serializers.py, app.py, test_helpers.py, tests/__init__.py.
  • Tests you can read and run: tests/test_part1_upload.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 Receipt Matching: Upload, OCR, Confirm 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?

Ramp. It is modelled on Ramp's round: Onsite AI live-coding round: a repository, a feature brief worded like a product request, any AI tool the candidate wants, bonus items once the core works; graded on how the brief is broken down and how the generated code is verified.

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?

3 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 Ramp runs its AI round, the AI coding interview guide.