Skip to main content

Checkpoint: Debug & Repair Lab

beginner45 min readLesson 59 of 180

Separate true reports from lies, fix the real defect, and leave behind an exhaustive regression net.

The repair lab - reproduce, hypothesize, fix, and prove the fix.

Inside the provided Solution skeleton, repair changeFor per the checkpoint. Two defects hide in the customer reports: one is real (negative input flows into % and prints negative coin counts), one is a lie (41 cents is actually miscounted in a sneakier way - your exhaustive 0..99 sweep in the tests is what catches arithmetic bugs a few spot checks never will).

Method reminder: reproduce first, form one hypothesis at a time, fix the cause, then add the test that would have caught it. The third test block is that test - it reconstructs every amount from its coin breakdown, so any future regression in the coinage logic fails loudly.