Code RoomRegex group index off-by-one sum
HardPrep Room Coding #4003

Regex group index off-by-one sum

Vibe & agenticNetworking & APIsSenior~18 min

An AI assistant wrote this Python to extract all dollar amounts from log lines and sum them, using a precompiled regex for speed:

On your three sample lines it returns the right total. What's the contract bug, and what input proves it?

Implement
sum_amount_cents(log_lines: list[str]) → int
Examples
in[["paid $12.50 to vendor","refund $3.00"]]out1550
in[["no amounts here","total: 42"]]out0
in[["$100 and $0.99"]]out10099
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.