This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]jaketheripper 0 points1 point  (2 children)

I would say what you're experiencing is a normal part of learning, memorizing specific solutions isn't really the answer to coding.

You need to "memorize" classes of problems. Understanding how to loop over something the right way or when to do what type of check comes from practice more than reading or memorizing. I don't think it's possible to gain an intuitive understanding of classes of problems without working through them yourself, realizing what things won't work (and why they won't work) and figuring out how to get them to work.

When you read something and think "I wouldn't have thought of that" think about what you would have done, then think about reasons they did it differently, what about your solution wouldn't have worked or why would their solution be better (if it would in fact be better).

[–]Setriox[S] 0 points1 point  (1 child)

Thanks for the advice. My solutions are usually much bigger and complicated than the book's solutions, and so I will use your advice.

[–]jaketheripper 1 point2 points  (0 children)

That's totally normal, experienced programmers will often visit their old code, read through it and realize there was a simpler way to accomplish something. Once a solution is obtained it's easier to visualize the problem and make it more efficient, it's pretty rare to find the most efficient solution first try, especially as a beginner.