Fixing by trial fails
transcript
The job gives three. The answer should be two. Quick fix: subtract one.
Subtract one from three. You get two. The example passes. It looks like the bug is gone. One example is not enough proof. Test more lists before you trust it.
Now try the list one, two. The job counts one rise. That is right. Subtracting one gives zero. That is wrong.
The same change fixes one list. It breaks the other. A change that fits one example is not a fix.
Trace a small list by hand. Find the first row that differs. Fix that line, and run both lists again. The cause is the loop start. It reads the last reading.
Save the failing list as a test. After the fix it must pass. It guards against the same bug. Run the old failing lists first. Then run the new ones.
Fix the cause, not the answer. Full breakdown in the lecture.