The Ultimate Guide to Solve Any Programming Problem Regardless of its Complexity!
By: Karina Pichardo
Tags: Problem Solving, Code, Programming, Computer Science, Effectiveness

1. Understand

Before you begin solving a problem make sure you fully understand what is being asked of you. I know “understanding” might seem like common sense but sometimes we’ll be so excited to start coding that we disregard this essential step.

It is extremely difficult to get a task done when you don’t know what is expected of you. This is how misunderstanding turns into major confusion.

Imagine wanting a dog to do something new without first training it to do it, the dog will try guessing what you want and do random acts because it has no idea where to even start.

This similar confusion happens when we attempt to code up a solution to a problem when we’re not sure what the outcome should be in the first place.

So, how do you know when you’ve truly reached an understanding? When you’re able to explain the problem and the expected outcome in your own words.

Tips to help create understanding:

Write it down

Doodle it

Read the problem out loud

Try explaining it out loud

Figure out what works for you, everyone is different.

2. Plan

Once you understand the problem, the next step to effective problem solving is planning. Don’t start coding up a solution without first planning for one.

It’s like writing a research paper, you wouldn’t just open up a word document and start typing away without first thinking about what ideas and facts or references you’re going to incorporate.

I mean, you could do it that way and it might work out, but I can guarantee you that this strategy will cause you to end up investing much more time and energy than it normally would if you took the time to plan / organize your ideas.

The same can be said about programming, programming requires organization. Don’t just hope you’ll find a way, plan for one to ensure you will.

Not planning ahead turns into trial and error, you wind up trying multiple things until you get lucky… this is not the best way to solve problems. You’ll be better off if you take a little extra time to plan your solution before beginning to code, trust me.

Tips for planning a solution:

Write down the exact steps you need to take in order to reach a solution. A useful way to do this in programming is with comments!

Consider this simple example:

“write a function that takes in two numbers and returns the sum”

A good question to ask yourself would be “if I have two numbers, what are the necessary steps that I need to take in order to get the sum of whatever numbers are passed into the function?”

The comments you see below are my step by step plan to execute this program.

JavaScript Code

3. Break the problem down

This is huge! Don’t look at a problem and try to solve the entire problem all at once. Not only is this intimidating but it’s also discouraging.

Photo by Markus Spiske on Unsplash

Imagine if someone gave you a jigsaw puzzle and told you to complete it. You wouldn’t just take all the puzzle pieces and try to put them all together in one shot.

You’d start with one piece and then go on to the next, and the next, and the next until finally you have achieved this awesome picture as a result.

The same goes for programming. Get into the habit of breaking down problems into smaller subset of problems. Start with one piece of the problem, and then move on the next problem, and the next problem until finally you’ve solved the entire thing.

You’ll go crazy if you try to solve the entire problem all at once, so don’t.

Tips for breaking down a problem:

Start by solving the sub problems which you already know how to solve, do this repeatedly till you solve all subset problems and then connect them together to get your final solution.