Code Room
Vibe codingHard
Question
An AI assistant wrote this Python to extract all dollar amounts from log lines and sum them, using a precompiled regex for speed:
import re AMOUNT = re.compile(r"\$(\d+(\.\d{2})?)") def sum_amounts(lines): total = 0.0 for line in lines: for m in AMOUNT.finditer(line): total += float(m.group()) return totalOn your three sample lines it returns the right total. What's the contract bug, and what input proves it?
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.
Learn the concepts
Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.
Run or narrate your approach, then ask the coach.