Problem solving

11 december 2018
Terug naar artikelen

“Everyone in this country should learn to program a computer, because it teaches you to think.” — Steve Jobs

A more effective way for problem solving; approaching from different perspectives. The most common way to approach solving problems will be something like this:

  • 1. Try a solution
  • 2. If the solution doesn’t work, try another one
  • 3. If that one also doesn’t work, repeat step 2 till the problem will be solved

Ofcourse there is nothing wrong with this way of solving problems, but this method will take a lot of time if it doesn’t work out the way you want.

What should you do when you encounter a problem?

Understand the problem

You need to know exactly what is being asked. You’ll know that you understand a problem if you can explain it. You can write down the problem; draw a doodle about it or tell someone about it. When you start to explain it, you will instantly see holes in the logic you did not see before.

Plan the solution ahead

Writing down the exact steps you will need to take to solve the problem will help you solving it. Give yourself time to think about the problem and eventually the solution. Start with analyzing it and processing the information you’ll gather.

If you can answer the following question, you’ll be ready to solve your problem: “Given input X, what are the steps necessary to return output Y?”

When you are writing code, comments are being made to help you remember the steps you’ve taken. And so the code will be self-explanatory

Divide the problem in multiple sub-problems

This will probably be the most important step of the problem solving. If you will try to solve the problem as a whole, you’ll encounter multiple situations in which you won’t get an answer. If you break the problem up in smaller problems it’ll be much easier to work your way through.

Start with solving the smallest/simplest problem. Once you’ve solved all the small problems you can connect the dots, to create the big answer to your problem.

Stuck??

The possibility that you can’t solve a small sub-problem is there. But that’s no problem at all. There are three things you can do when you’re facing a situation like this:

  • – Debugging! Go through your solution and try to find where it when wrong.
  • – Different perspective: take a step back and try to look at the problem from a different perspective. If you’re getting the idea that nothing works. Just delete everything you gathered, and start from the beginning. Starting over with a fresh look on the problem will be very effective.
  • – Researching; there is always someone on the internet who has solved your problem, or something similiar to it. Just try to use this persons outcome and forge it to your situation.
  • Practicing

    If you want to be good at solving problems; solve a lot of problems! The only way you’ll get better at it, is by doing it. It’ll be a matter of time before you recognize: “this problem could easily solved by doing “this””.

    Practicing can be done with: chess, math problems, sudoku, video-games, monopoly, etc. Try to find something that you will enjoy doing; so that problem-solving will be something fun.

    https://medium.freecodecamp.org/how-to-think-like-a-programmer-lessons-in-problem-solving-d1d8bf1de7d2