TL;DR: Turn the sentence into explicit rules with their inputs. The customer being served comes from the session; the order must belong to that customer; the amount is in the order's currency and cannot exceed what remains refundable; the limit applies to the sum of refunds for this order (and per customer per period) so it cannot be split; at or below $100 it is allowed, above it needs an approval bound to this exact refund. Encode the rules in a policy engine, test every boundary with a case table, and log each decision with the rule that made it.
How to approach it
Interrogate the sentence before writing anything: list the ambiguities, decide each with the business owner, then encode and test.
A strong answer
Decisions hidden in the sentence.
| Question | Decision |
|---|---|
| Who is "the customer being served"? | The authenticated customer of this session, never a model argument |
| Which orders? | Orders owned by that customer |
| Currency? | The order's currency; the limit converted at a fixed rate table, or set per currency |
| Up to $100 of what? | Total refunds on the order, including earlier ones, so a $180 refund cannot be split into two $90s |
| Per customer limits? | Total refunds per customer per 30 days capped too (for example $300) |
| Exactly $100? | Allowed (up to and including) |
| Approval by whom? | Support lead role, bound to this refund's amount and order |
The rule.
def refund_decision(req, ctx):
if req["customer"] != ctx["session_customer"]:
return "deny", "not the customer being served"
order = ctx["order"]
if order["owner"] != ctx["session_customer"]:
return "deny", "order belongs to someone else"
refundable = order["paid"] - order["refunded"]
if req["amount"] <= 0 or req["amount"] > refundable:
return "deny", f"amount must be between 0 and {refundable}"
order_total = order["refunded"] + req["amount"]
period_total = ctx["customer_refunds_30d"] + req["amount"]
if order_total <= 100 and period_total <= 300:
return "allow", "within limits"
if ctx.get("approval") == ("support_lead", req["order"], req["amount"]):
return "allow", "approved by support lead"
return "needs_approval", f"order total {order_total}, 30-day total {period_total}"
def case(amount, refunded=0, period=0, approval=None, owner="c_1"):
req = {"customer": "c_1", "order": "o_9", "amount": amount}
ctx = {"session_customer": "c_1", "customer_refunds_30d": period,
"approval": approval,
"order": {"owner": owner, "paid": 250, "refunded": refunded}}
return refund_decision(req, ctx)[0]
TABLE = [(case(100), "allow"), (case(100.01), "needs_approval"),
(case(60, refunded=60), "needs_approval"), # split refunds count
(case(50, period=280), "needs_approval"), # 30-day cap
(case(140, approval=("support_lead", "o_9", 140)), "allow"),
(case(140, approval=("support_lead", "o_9", 120)), "needs_approval"),
(case(300), "deny"), (case(40, owner="c_2"), "deny")]
print(all(got == want for got, want in TABLE), len(TABLE)) # => True 8
Every boundary has a case: exactly $100, a cent over, a split attempt, the period cap, an approval for a different amount, more than refundable, and someone else's order.
Operate it. The rule lives in the policy engine, versioned; the table runs in CI; changes run in shadow first; each decision logs the inputs, the outcome and the reason; approvals expire and are bound to order and amount.
What interviewers probe next
"Why does an approval for $120 not cover $140?" The approver judged $120. A different amount is a different decision.
"What about refunds to a different card?" A separate rule: refunds go to the original payment method unless a lead approves otherwise.
"Isn't this over-engineered for one sentence?" The sentence is where money leaves the company. Each case in the table is a way it could leave wrongly.
How it's scored
Weak: if amount <= 100: allow else: ask in the tool handler, with the customer taken from arguments.
Hire: Session customer, ownership check, threshold and approval in a policy engine.
Strong Hire: Brings out the hidden decisions (identity, ownership, currency, cumulative and per-period totals, boundary, approval binding), encodes them with clear reasons, tests every edge with a case table, and operates the rule with versioning, shadow rollout and decision logs.
Common mistakes
- Customer identity from model arguments.
- Per-refund limits that allow splitting.
- Approvals not bound to amount and order.
- No tests at the boundaries.