๐ WAYPOINT LESSON
Fix the cause, not the symptom
โญโญโญ advancedโณ 10 min read๐ Lesson 218 of 256
One token usually; re-run the WHOLE test set; say the one-sentence correction before typing.
Fix discipline. When you find the line, the fix is usually one token โ but three rules keep the fix honest:
- Fix the cause, not the symptom. If the streak counter never
resets, the bug is the missing
elseโ not a clampingifstapled at the end. Symptom fixes pass the given example and fail the hidden ones. - Re-run the WHOLE test set, not just the failing case. A fix that repairs case 3 and breaks case 1 traded one bug for another. The graded challenges here re-run everything.
- Say the one-sentence correction: "the loop must run while
i + k <= length, noti + k < length." If you cannot say the sentence, you have not found the bug โ you have found a symptom.
This module's broken solutions each hide exactly one bug; your fixed version must pass ALL tests including the boundary ones the original author forgot.
โก Now practice
Ready to CodeDebug gauntlet: one bug eachFour broken methods with single subtle bugs; diagnose, name, fix.
4 challenges ยท ยท ~55 min