How to properly approach solving a programming problem

Today I’ve found a reply on r/learnprogramming that best describes how to approach solving a programming problem. It was written by “desrtfx” on reddit.

As a programmer, you need to learn to think in a different way: you need to think in algorithms (and in steps). This is the biggest challenge that aspiring programmers face. The only cure for that problem is to practice, practice, practice, and practice more.

Beginners quite commonly make the mistake of directly going to the keyboard and starting to program away when they are given a problem to solve. Don’t do that. Read the problem description multiple times and then go away from the computer. Ponder about the problem, work through the problem on paper without thinking about actual programming. Devise an abstract solution for your problem (at least describe the way that you as a person, not as the computer would solve the problem). Explain the problem to an inanimate object (Rubber Duck Debugging). Give your brain time to process the information/the problem description. Do something different for a bit of time. Go outside, go for a walk, take a shower, do whatever you want - away from the computer. Get back to the problem after you have spent some time pondering about it.

A good programmer takes some time to analyze the problem before even thinking about writing a program to solve the problem. This is an essential step.

Break the problem down into smaller, easier manageable parts. (set-up with initialization of the variables, input, processing, and finally output) and then attack each part individually. This makes the whole easier to manage.

Programming is no easy task. It takes time and lots of effort to learn. The modern courses make it seem way easier (and Codecademy is extremely good in passing this feeling, but extremely bad in actually teaching) than it actually is.

There is a good book on pre-oder: Think like a Programmer (Python edition) and its already existing counterpart: Think like a Programmer (C++ edition). These books explain the thought process of a programmer from an abstract point of view. The actual programming is secondary.

Don’t give up. It gets easier with lots and lots of practice.

Original post and comment can be found here.


This is informative and helpful. Twenty years ago I was a CS student and I remember breaking down problems in flow charts and then writing the code. I am working on Codecademy and FCC and have yet to run into any thing like how to break down a problem from what the user wants and then turning it in to code. This post is a good place to start, does anyone have a source on the steps of breaking down a problem logically, turning that into ‘pseudo code’, and then into say Javascript?

1 Like

It’s called “Computational Thinking

Wiki article


Great advice. The most recent mini-project I did (typewriter effect) was the first time I really applied this approach, having failed with the “throw things at it til something sticks” approach, which got me through most of the projects and algorithm challenges up until now. The level of understanding and sense of achievement were much higher, with much less wasted time and better quality code in the end.

You guys are over complicated things.
The more you practice, the easier the process becomes. I dislike “special” method to make things easier when all you need is more experience.

You can’t do that practice if you don’t know how to solve problems.

Back in the early 1990’s when I was at university our Pascal lecturer drummed the use of psuedo code into us. I didn’t have a computer at home but used to write the psuedo code out at home and then transform into Pascal on paper ready to type into the computer at university next day. Still use tpsuedo-code +pen +paper today!