r/learnprogramming • u/astronautfromuranus • 10h ago
Tutorial How can I become good at problem solving?
After getting a task some programmers just starting writing the code, while writing the code they understands all the logic behind that...how can i achieve that level of skill?
6
Upvotes
3
u/grantrules 10h ago
How do people become good at playing piano? How do people become good at hitting a baseball? How do people become good at tapdancing? How do people become good at writing poetry?
Practice.
https://adventofcode.com/
2
u/SnugglyCoderGuy 10h ago
Practice.
The number one rule of problem solving is if you can't solve the problem in front of you then break it up into smaller problems. Keep breaking the problems up until you do get a problem you can solve, then solve it. Do this recursively and eventually you solve enough problems that you've solved your original problem.
3
u/JohnsTech_dev 10h ago
a lot of those people who just start typing are rewriting stuff they've already done 20 times, so the logic looks free to them. it isnt really. what helped me was writing the input and the expected output of the function as a comment first, then one tiny example by hand on paper. if i cant do the example by hand i have no business writing the code yet. after a few months you start seeing the same shapes, like two pointers or a lookup table, and it gets quicker
1
u/LifeguardImportant44 9h ago
Half the time they already wrote that exact loop fifty times before so it looks like magic from the outside
1
u/EszterSantos72 9h ago
Write code for at least 50 small problems before expecting it to click, because that's when you start seeing patterns repeat. Early on, force yourself to write out your logic in comments first so you don't get lost mid-solution.
1
u/Ahmed_Hisham0 7h ago
they can't do that because they're smarter. they've just seen that shape of problem before, so the first draft is already roughly right.
the way you get there is by writing the steps in plain words before touching the keyboard. like "read the file, keep a running total, skip blank lines". if you can't write the steps, you don't know the problem yet and typing will just be guessing.
also, start smaller than feels useful. ten tiny problems teaches more than one big one you fight for a week.
1
u/aqua_regis 7h ago
By learning to first do your own, individual research, as in just typing "problem solving" into reddit's search box.
Also, practice, practice, practice, practice, and more practice.
You need to solve problems to train your problem solving skills. Tutorials are not going to teach you such skills.
Below are some of similar posts (where the posters usually proved way more effort than you did):
And finally, some book suggestions:
Last, a great practice site: https://exercism.org
1
u/Jackson999Jc 6h ago
honestly the thing that helped me most was writing the plan in plain english comments before any code. like 4-5 lines of "first this, then that, edge case here". the people who just start typing usually have done that exact kind of problem 50 times so the plan lives in their head. you get there by solving lots of small problems and then asking yourself what pattern it was after, not just whether it passed.
1
u/Downtown_Savings_730 6h ago
Keep on solving problems, ultimately problem solving boils down to pattern recognition and those who can figure out what pattern to use can solve problems easily