Code RoomDiscount validation missing bounds
HardPrep Room Coding #4414

Discount validation missing bounds

Vibe & agenticAlgorithms & data structuresSenior~18 min

An AI wrote this DRF endpoint to apply a discount to an order. The serializer 'validates' the payload. Finance discovers orders with negative totals and 300% discounts. Explain why validation didn't stop it and fix it.

Implement
screen_discount_requests(percents: list[float], max_percent: float) → list[str]
Examples
in[[10,300,-50],25]out["accepted","rejected_above_100","rejected_negative"]
in[[25,25.5],25]out["accepted","rejected_above_policy"]
in[[],50]out[]
What a strong answer looks like

Treat the AI’s output as a draft to verify, not an answer to trust. Name the specific flaw and the input that triggers it, say how you’d catch it (tests, edge cases, reading critically), and how you’d re-prompt or decompose to get it right.

0:00 of about 18 min

Vibe & agentic: describe the solution in plain language (or narrate it) and the coach grades your approach.

Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.