Problem
Build a PricingEngine that prices a Home as final = base + renovation + riskAdjustment + marketAdjustment. Each component is produced by its own rule and recorded in a breakdown() map keyed by component name; the recorded components must always sum to the returned price. price(Home) returns the final int price. setOverride(int) sets a manual override that wins over the computed total — when an override is active, price() returns the override and the breakdown still sums to it. Model the rules as a list of strategy objects so each one contributes one labeled part.
The AI is deliberately fallible — it gives hints, not solutions, and sometimes proposes wrong code. It cannot touch your editor. Paste what you choose, then Run. Anything AI-derived stays UNVERIFIED until your tests go green.
Self-check
- ☐final = base + renovation + riskAdjustment + marketAdjustment when no override is set
- ☐breakdown() contains a labeled entry for every rule (base, renovation, riskAdjustment, marketAdjustment)
- ☐the breakdown components sum exactly to the price returned by price()
- ☐setOverride makes price() return the override value, ignoring the computed total
- ☐the breakdown still sums to the price even when the override is active (don't let the invariant break)
- ☐rules are a list of strategy-ish objects, not a hardcoded arithmetic expression — adding a 5th rule should not touch price()
Hints / what this doesn't test
This is an Opendoor-flavored applied problem: a small rule engine that prices a home and stays auditable — every dollar in the final price must trace back to a labeled component. Restate it before coding — "So the price is a sum of named parts, the breakdown has to add up to what I return, and a manual override replaces the total — but I still owe a breakdown that sums to it?"
What this problem does not test (say so out loud): rule ordering/priority,
percentage-based (multiplicative) adjustments, per-rule enable/disable flags,
floating-point money (everything is int cents-or-dollars here), and persistence are
out of scope — but a senior names that the easy-to-miss bug is letting setOverride
break the breakdown-sums-to-price invariant, which is exactly what makes the engine
auditable in the first place.
Tests
- ○sums_components
- ○breakdown_has_each_part
- ○override_wins
Pair partner (병신 모드 · 버그 잡기)
gpt-4o-miniAsk for a skeleton or a test plan — not the answer. Then implement the core yourself and come back for edge cases. Remember: the partner is fallible. Verify everything by running it.
The partner sees your editor but cannot change it. Copy any suggestion in by hand, then Run to verify.
AI랑 먼저 페어하고 눌러