Prove what is true right now
Guessing looks like changing three lines at once and hoping the output improves. Method looks like this: reproduce the bug with the smallest input, state what you expected versus what you got, inspect the values at the failure point, change one hypothesis, run again. If you cannot reproduce it, you cannot fix it. If you change five things, you will not know which change mattered.
Print statements (or a debugger) are not shameful. They are sensors. Print the input after you parse it. Print the loop index. Print the value before the crash. In languages with a compiler, fix the first diagnostic first. Then write a tiny case that used to fail and keep it — that is the seed of a test.
A five-step card you can reuse
- Reproduce with the smallest input.
- Write expected vs actual in one sentence.
- Inspect values at the failing line.
- Form one hypothesis; change only that.
- Run again. Keep the failing case for next time.
If you have been stuck for twenty minutes with no new information, shrink the program. Comment out half. Find which half still breaks.
Labs help because Check already owns the expected output. Use that. When your solution fails a hidden test, craft a new example yourself. Pair with How to Read Error Messages so the toolchain and your method work together.