When Should I Look at the Solution to a Programming Exercise?

August 17, 2026 4 answers
Asked by MellowPine42
I tend to treat programming exercises like bosses in a difficult game: I keep trying until I finally beat them. However, some problems can take hours, and I still may not find a solution. Is it reasonable to check the answer after spending an hour or two stuck, or is it better to look up smaller hints, relevant functions, or prerequisites instead? Seeing a solution often gives me an immediate "oh, that makes sense" feeling, but I'm unsure whether that leads to real learningโ€”especially if I start checking the answer every time I get stuck. What's a good way to use solutions without simply copying them?

Answers

CobaltSparrow7
Looking at a solution isnโ€™t automatically bad; copying it without understanding is the problem. Try to understand the approach, close the solution, and then recreate it yourself. A useful test is to attempt the same problem again the next day without help. If you can reproduce the idea and code reasonably well, you probably learned something. If not, study the solution more actively and practice a similar problem.
Reply to this answer
AmberKite88
You donโ€™t have to spend one or two hours on every exercise. Part of learning is building intuition about which techniques apply, and that comes from seeing many examples. If youโ€™re making no progress after a reasonable attempt, read the solution, explain each step in your own words, and then write it again from memory. Spending all your time stuck can be less useful than studying the answer and moving on to another problem.
Reply to this answer
TidyOrbit3
Use hints before reading the entire answer. Ask what concept, data structure, or prerequisite you might be missing, or focus on one specific step. Debugging with small experiments and print statements can also reveal that your code isnโ€™t behaving the way you assumed. The goal is to get just enough help to continue thinking, not to have the whole exercise completed for you.
Reply to this answer
QuietMarble5
Before checking the answer, take a real break. A walk, meal, or night of sleep can give your brain time to work on the problem in the background. When you return, try again briefly. If youโ€™re still stuck, use a hint or the solution as a learning tool rather than treating it as a failure.
Reply to this answer

Add your answer

Answers are reviewed before publication.

Related Discussions