Stage 1 of 4: Flag rules
Background. A payments team writes rules such as BLOCK if fraud_flag and applies them, in order, to every transaction. README.md is the contract: data model, evaluation order, the default, what a missing field does. Read it first; the tests are written against it.
rules.py holds RuleProcessor, which is still a stub.
Implement RuleProcessor(rules, default) and evaluate(transaction) for flag rules. A condition is one field name; it matches when the transaction has that field set to the boolean True.
Example
rules = ["BLOCK if fraud_flag", "ACCEPT if trusted_partner"]
evaluate({"fraud_flag": False, "trusted_partner": True}) -> "ACCEPT"
evaluate({"fraud_flag": True, "trusted_partner": True}) -> "BLOCK"
evaluate({"amount": 1200}) -> default
Done when Submit goes green.
Constraints
- Python 3.12+ standard library only
- Time limit: 10 seconds per test
- Editable:
rules.py - Read-only:
README.md, 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: Comparisons with AND and OR. Comparisons joined by AND and OR, with precedence and missing fields done right.
- Stage 3: String literals. String literals in quotes, including ones that contain AND, OR and operators.
- Stage 4: Reject malformed rules. Reject malformed rules at construction, and never raise on a bad transaction.
The files you get
- Yours to edit: rules.py.
- Read-only: README.md, tests/__init__.py.
- Tests you can read and run: tests/test_part1_flags.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 Transaction Rule Parser free?
Stage 1 is free with an account. The other 3 stages need Nyrion Pro.
Which company asks something like this?
Stripe. It is modelled on Stripe's round: AI-assisted coding round in HackerRank with an embedded assistant (Claude, Gemini or Codex): a README, a rule parser built in parts, about 30 minutes of coding, graded on how you delegate and validate. In the onsite loop and increasingly the phone screen.
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 first stage of this problem is free.
More like it: every practice problem, how Stripe runs its AI round, the AI coding interview guide.