5 Steps to Solving Programming Problems

Solving problems is a programmer’s bread and butter, and everyone has their own method, I personally found 5 steps that most likely than not will help you, not only to solve problems but to do it faster and more efficiently.

1. Read the problem several times until you can explain it to someone else

Read Read Read!!

This is by far, the most important step, read the problem several times, until you fully understand it, if you don’t understand it, you won’t be able to solve it. the best way to know if you understand the problem is by being able to explain it to someone else.

2. Solve the problem manually

Nothing can be automated that cannot be done manually!

Any code we write has a foundation, and it is the manual process. That being said, solve the problem manually first, that way you know exactly what you want to automate, this will save you a lot of time wasted if you just start writing code like a maniac.

Test your process with more than one input and some corner cases to validate it, pay close attention to every single step you take in your head, write it down, as each one counts.

3. Make your manual solution better

See if you can make your process better, if there is an easier way to do it or if there are some steps you can cut to simplify it (like loops). This step is very important, remember that is much easier to reconstruct your process in your head than it is in your code.

At this point you will be tempted to write some code, don’t do it yet, we have one more step to cover, I promise you it will make your final code easier to write.

4. Write pseudo code

Pseudocode  is a detailed  description of what a program must do, this will help you write every line of code needed in order to solve your problem.

Experienced programmers sometimes omit this step, but I can assure you no matter how experienced you are, if you write some pseudo code, the process of writing your final code will be much easier since you only have to translate each line of pseudo code into actual code.

ie. square (n)

# initialize a variable with a 'n' value

# Multiply variable by it self

# Return the result of that multiplication

Now we know exactly what our code is supposed to do, we have one more step… can you guess it?

5. Replace pseudo-code with real code

Here it is the fun part, now that you know for sure what your program should do, just write some code and test it. remember you can always make your code better along the way.

Lets use our square example:

def square(n)
  variable = n   #=> initialize a variable with a 'n' value
  answer = variable * variable   #=>  Multiply variable by it self
  Return answer    # Return the result of that multiplication

Then we optimize it:

def square(n)
  n * n

# I Know! Ruby is amazing!!

No matter how complex your problem is, I assure you these 5 steps will help you solve it in less time and with fewer headaches.

Note: If your problem is too complex, divide it into small problems, it’s a technique called “Divide and conquer”.

Adrian Prieto

“If you are not willing to learn, no one can help you. If you are determined to learn, no one can stop you.” ― Zig Ziglar

Latest posts by Adrian Prieto (see all)

You may also like


  1. Hello! I’ve been following your blog for a little while now and ultimately got the courage to go on and provide you with a shout from Porter Texas!
    Just wanted to say maintain the fantastic job!

  2. Heya! I understand this is somewhat off-topic however I had to
    ask. Does operating a well-established website like yours take a massive amount work?
    I’m brand new to running a blog however I do write in my journal everyday.
    I’d like to start a blog so I can share my own experience and thoughts online.
    Please let me know if you have any ideas or tips for new aspiring blog owners.
    Appreciate it!

  3. Howdy! This really is my first visit to your blog!
    Our company is a collection of volunteers and starting a brand new initiative within a community from the
    same niche. Your website provided us beneficial information to work on. You might have done a marvellous job!

  4. You’ve made some good points there. I checked on the
    internet for more information in regards to the issue
    and discovered most people goes together with your views on this amazing site.

  5. Perhaps you have considered creating an e-book or guest
    authoring on other blogs? We have your blog based about the same information you discuss and would love to have you share some stories/information. I am aware my subscribers would appreciate
    your projects. If you will be even remotely interested, you may want to send
    me an e-mail.

  6. I do like this and generally follow the same steps, but I differ on step 4. Rather than writing pseudocode I write unit tests, as I find this is a better tool for thinking through a problem. When I would write pseudocode I found myself trying to think through all the various possibilities at once, which is overwhelming. If I did unit tests, I could write one unit test to cover one possible output, then write the code to handle that one case, then repeat steps 4 & 5 for other cases. I find this works well because it’s more incremental.

    1. I understand your point, but I think testing is a step you follow once you know how to accomplish the task at hand. Thank you for your feedback.

Leave a Reply

Your email address will not be published. Required fields are marked *