
Member-only story
10 Steps to Solving a Programming Problem
Tips for new developers staring at a blank screen, unsure of where to start
Some of the feedback I hear from new developers working on a programming problem revolves around uncertainty of where to start. You understand the problem, the logic, basics of the syntax, etc. If you see someone else’s code or have someone to guide you, you can follow along. But maybe you feel uncertain about doing it yourself and have trouble turning your thoughts into code at first even though you understand the syntax or logic. Here’s my process and some tips to tackling a sample problem that hopefully some of you may find helpful in your journey.
1. Read the problem at least three times (or however many makes you feel comfortable)
You can’t solve a problem you don’t understand. There is a difference between the problem and the problem you think you are solving. It’s easy to start reading the first few lines in a problem and assume the rest of it because it’s similar to something you’ve seen in the past. If you are making even a popular game like Hangman, be sure to read through any rules even if you’ve played it before. I once was asked to make a game like Hangman that I realized was “Evil Hangman” only after I read through the instructions (it was a trick!).
Sometimes I’ll even try explaining the problem to a friend and see if her understanding of my explanation matches the problem I am tasked with. You don’t want to find out halfway through that you misunderstood the problem. Taking extra time in the beginning is worth it. The better you understand the problem, the easier it will be to solve it.
Let’s pretend we are creating a simple function selectEvenNumbers
that will take in an array of numbers and return an array evenNumbers
of only even numbers. If there are no even numbers, return the empty array evenNumbers
.
function selectEvenNumbers() {
// your code here
}
Here are some questions that run through my mind:
- How can a computer tell what is an even number? Divide that number by 2 and see if its remainder is 0.
- What am I passing into this function? An array