How to Solve Coding Problems with a Simple Four Step Method

Madison Kanna

I had fifteen minutes left, and I knew I was going to fail.

I had spent two months studying for my first technical interview.

I thought I was prepared, but as the interview came to a close, it hit me: I had no idea how to solve coding problems.

Of all the tutorials I had taken when I was learning to code, not one of them had included an approach to solving coding problems.

I had to find a method for problem-solving—my career as a developer depended on it.

I immediately began researching methods. And I found one. In fact, what I uncovered was an invaluable strategy. It was a time-tested four-step method that was somehow under the radar in the developer ecosystem.

In this article, I’ll go over this four-step problem-solving method that you can use to start confidently solving coding problems.

Solving coding problems is not only part of the developer job interview process—it’s what a developer does all day. After all, writing code is problem-solving.

A method for solving problems

This method is from the book How to Solve It by George Pólya. It originally came out in 1945 and has sold over one million copies.

His problem-solving method has been used and taught by many programmers, from computer science professors (see Udacity’s Intro to CS course taught by professor David Evans) to modern web development teachers like Colt Steele.

Let’s walk through solving a simple coding problem using the four-step problem-solving method. This allows us to see the method in action as we learn it. We'll use JavaScript as our language of choice. Here’s the problem:

Create a function that adds together two numbers and returns that value. There are four steps to the problem-solving method:

  • Understand the problem.
  • Devise a plan.
  • Carry out the plan.

Let’s get started with step one.

Step 1: Understand the problem.

When given a coding problem in an interview, it’s tempting to rush into coding. This is hard to avoid, especially if you have a time limit.

However, try to resist this urge. Make sure you actually understand the problem before you get started with solving it.

Read through the problem. If you’re in an interview, you could read through the problem out loud if that helps you slow down.

As you read through the problem, clarify any part of it you do not understand. If you’re in an interview, you can do this by asking your interviewer questions about the problem description. If you’re on your own, think through and/or Google parts of the question you might not understand.

This first step is vital as we often don’t take the time to fully understand the problem. When you don’t fully understand the problem, you’ll have a much harder time solving it.

To help you better understand the problem, ask yourself:

What are the inputs?

What kinds of inputs will go into this problem? In this example, the inputs are the arguments that our function will take.

Just from reading the problem description so far, we know that the inputs will be numbers. But to be more specific about what the inputs will be, we can ask:

Will the inputs always be just two numbers? What should happen if our function receives as input three numbers?

Here we could ask the interviewer for clarification, or look at the problem description further.

The coding problem might have a note saying, “You should only ever expect two inputs into the function.” If so, you know how to proceed. You can get more specific, as you’ll likely realize that you need to ask more questions on what kinds of inputs you might be receiving.

Will the inputs always be numbers? What should our function do if we receive the inputs “a” and “b”? Clarify whether or not our function will always take in numbers.

Optionally, you could write down possible inputs in a code comment to get a sense of what they’ll look like:

//inputs: 2, 4

What are the outputs?

What will this function return? In this case, the output will be one number that is the result of the two number inputs. Make sure you understand what your outputs will be.

Create some examples.

Once you have a grasp of the problem and know the possible inputs and outputs, you can start working on some concrete examples.

Examples can also be used as sanity checks to test your eventual problem. Most code challenge editors that you’ll work in (whether it’s in an interview or just using a site like Codewars or HackerRank) have examples or test cases already written for you. Even so, writing out your own examples can help you cement your understanding of the problem.

Start with a simple example or two of possible inputs and outputs. Let's return to our addition function.

Let’s call our function “add.”

What’s an example input? Example input might be:

// add(2, 3)

What is the output to this? To write the example output, we can write:

// add(2, 3) ---> 5

This indicates that our function will take in an input of 2 and 3 and return 5 as its output.

Create complex examples.

By walking through more complex examples, you can take the time to look for edge cases you might need to account for.

For example, what should we do if our inputs are strings instead of numbers? What if we have as input two strings, for example, add('a', 'b')?

Your interviewer might possibly tell you to return an error message if there are any inputs that are not numbers. If so, you can add a code comment to handle this case if it helps you remember you need to do this.

Your interviewer might also tell you to assume that your inputs will always be numbers, in which case you don’t need to write any extra code to handle this particular input edge case.

If you don’t have an interviewer and you’re just solving this problem, the problem might say what happens when you enter invalid inputs.

For example, some problems will say, “If there are zero inputs, return undefined.” For cases like this, you can optionally write a comment.

// check if there are no inputs.

// If no inputs, return undefined.

For our purposes, we’ll assume that our inputs will always be numbers. But generally, it’s good to think about edge cases.

Computer science professor Evans says to write what developers call defensive code. Think about what could go wrong and how your code could defend against possible errors.  

Before we move on to step 2, let’s summarize step 1, understand the problem:

-Read through the problem.

-What are the inputs?

-What are the outputs?

Create simple examples, then create more complex ones.

2. Devise a plan for solving the problem.

Next, devise a plan for how you’ll solve the problem. As you devise a plan, write it out in pseudocode.

Pseudocode is a plain language description of the steps in an algorithm. In other words, your pseudocode is your step-by-step plan for how to solve the problem.

Write out the steps you need to take to solve the problem. For a more complicated problem, you’d have more steps. For this problem, you could write:

// Create a sum variable.

Add the first input to the second input using the addition operator .

// Store value of both inputs into sum variable.

// Return as output the sum variable. Now you have your step-by-step plan to solve the problem. For more complex problems, professor Evans notes, “Consider systematically how a human solves the problem.” That is, forget about how your code might solve the problem for a moment, and think about how you would solve it as a human. This can help you see the steps more clearly.

3. Carry out the plan (Solve the problem!)

Hand, Rubik, Cube, Puzzle, Game, Rubik Cube

The next step in the problem-solving strategy is to solve the problem. Using your pseudocode as your guide, write out your actual code.

Professor Evans suggests focusing on a simple, mechanical solution. The easier and simpler your solution is, the more likely you can program it correctly.

Taking our pseudocode, we could now write this:

Professor Evans adds, remember not to prematurely optimize. That is, you might be tempted to start saying, “Wait, I’m doing this and it’s going to be inefficient code!”

First, just get out your simple, mechanical solution.

What if you can’t solve the entire problem? What if there's a part of it you still don't know how to solve?

Colt Steele gives great advice here: If you can’t solve part of the problem, ignore that hard part that’s tripping you up. Instead, focus on everything else that you can start writing.

Temporarily ignore that difficult part of the problem you don’t quite understand and write out the other parts. Once this is done, come back to the harder part.

This allows you to get at least some of the problem finished. And often, you’ll realize how to tackle that harder part of the problem once you come back to it.

Step 4: Look back over what you've done.

Once your solution is working, take the time to reflect on it and figure out how to make improvements. This might be the time you refactor your solution into a more efficient one.

As you look at your work, here are some questions Colt Steele suggests you ask yourself to figure out how you can improve your solution:

  • Can you derive the result differently? What other approaches are there that are viable?
  • Can you understand it at a glance? Does it make sense?
  • Can you use the result or method for some other problem?
  • Can you improve the performance of your solution?
  • Can you think of other ways to refactor?
  • How have other people solved this problem?

One way we might refactor our problem to make our code more concise: removing our variable and using an implicit return:

With step 4, your problem might never feel finished. Even great developers still write code that they later look at and want to change. These are guiding questions that can help you.

If you still have time in an interview, you can go through this step and make your solution better. If you are coding on your own, take the time to go over these steps.

When I’m practicing coding on my own, I almost always look at the solutions out there that are more elegant or effective than what I’ve come up with.

Wrapping Up

In this post, we’ve gone over the four-step problem-solving strategy for solving coding problems.

Let's review them here:

  • Step 1: understand the problem.
  • Step 2: create a step-by-step plan for how you’ll solve it .
  • Step 3: carry out the plan and write the actual code.
  • Step 4: look back and possibly refactor your solution if it could be better.

Practicing this problem-solving method has immensely helped me in my technical interviews and in my job as a developer. If you don't feel confident when it comes to solving coding problems, just remember that problem-solving is a skill that anyone can get better at with time and practice.

If you enjoyed this post, join my coding club , where we tackle coding challenges together every Sunday and support each other as we learn new technologies.

If you have feedback or questions on this post, feel free to tweet me @madisonkanna ..

Read more posts .

If you read this far, thank the author to show them you care. Say Thanks

Learn to code for free. freeCodeCamp's open source curriculum has helped more than 40,000 people get jobs as developers. Get started

steps of problem solving in programming

Member-only story

10 Steps to Solving a Programming Problem

Tips for new developers staring at a blank screen, unsure of where to start.

Valinda Chan

Valinda Chan

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 .

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
  • What will that array contain? One or more numbers
  • What are the data types of the elements in the array? Numbers
  • What is the goal of this function? What am I returning at the end of this function? The goal is to take all the even numbers and return them in an array. If there are no even numbers, return an empty array.

2. Work through the problem manually with at least three sets of sample data

Take out a piece of paper and work through the problem manually. Think of at least three sets of sample data you can use. Consider corner and edge cases as well.

Corner case : a problem or situation that occurs outside of normal operating parameters, specifically when multiple environmental variables or conditions are simultaneously at extreme levels, even though each parameter is within the specified range for that parameter. Edge case : problem or situation that occurs only at an extreme (maximum or minimum) operating parameter

For example, below are some sets of sample data to use:

When you are first starting out, it is easy to gloss over the steps. Because your brain may already be familiar with even numbers, you may just look at a sample set of data and pull out numbers like 2 , 4 , 6 and so forth in the array without fully being aware of each and every step your brain is taking to solve it. If this is challenging, try using large sets of data as it will override your brain’s ability to naturally solve the problem just by looking at it. That helps you work through the real algorithm.

Let’s go through the first array [1]

  • Look at the only element in the array [1]
  • Decide if it is even. It is not
  • Notice that there are no more elements in this array
  • Determine there are no even numbers in this provided array
  • Return an empty array

Let’s go through the array [1, 2]

  • Look at the first element in array [1, 2]
  • Look at the next element in the array
  • Decide if it is even. It is even
  • Make an array evenNumbers and add 2 to this array
  • Return the array evenNumbers which is [2]

I go through this a few more times. Notice how the steps I wrote down for [1] varies slightly from [1, 2] . That is why I try to go through a couple of different sets. I have some sets with just one element, some with floats instead of just integers, some with multiple digits in an element, and some with negatives just to be safe.

3. Simplify and optimize your steps

Look for patterns and see if there’s anything you can generalize. See if you can reduce any steps or if you are repeating any steps.

  • Create a function selectEvenNumbers
  • Create a new empty array evenNumbers where I store even numbers, if any
  • Go through each element in the array [1, 2]
  • Find the first element
  • Decide if it is even by seeing if it is divisible by 2. If it is even, I add that to evenNumbers
  • Find the next element
  • Repeat step #4
  • Repeat step #5 and #4 until there are no more elements in this array
  • Return the array evenNumbers , regardless of whether it has anything in it

This approach may remind you of Mathematical Induction in that you:

  • Show it is true for n = 1 , n = 2 , ...
  • Suppose it is true for n = k
  • Prove it is true for n = k + 1

4. Write pseudocode

Even after you’ve worked out general steps, writing out pseudocode that you can translate into code will help with defining the structure of your code and make coding a lot easier. Write pseudocode line by line. You can do this either on paper or as comments in your code editor. If you’re starting out and find blank screens to be daunting or distracting, I recommend doing it on paper.

Pseudocode generally does not actually have specific rules in particular but sometimes, I might end up including some syntax from a language just because I am familiar enough with an aspect of the programming language. Don’t get caught up with the syntax. Focus on the logic and steps.

For our problem, there are many different ways to do this. For example, you can use filter but for the sake of keeping this example as easy to follow along as possible, we will use a basic for loop for now (but we will use filter later when we refactor our code).

Here is an example of pseudocode that has more words:

Here is an example of pseudocode that has fewer words:

Either way is fine as long as you are writing it out line-by-line and understand the logic on each line.

Refer back to the problem to make sure you are on track.

5. Translate pseudocode into code and debug

When you have your pseudocode ready, translate each line into real code in the language you are working on. We will use JavaScript for this example.

If you wrote it out on paper, type this up as comments in your code editor. Then replace each line in your pseudocode.

Then I call the function and give it some sample sets of data we used earlier. I use them to see if my code returns the results I want. You can also write tests to check if the actual output is equal to the expected output.

I generally use console.log() after each variable or line or so. This helps me check if the values and code are behaving as expected before I move on . By doing this, I catch any issues before I get too far. Below is an example of what values I would check when I am first starting out. I do this throughout my code as I type it out.

After working though each line of my pseudocode, below is what we end up with. // is what the line was in pseudocode. Text that is bolded is the actual code in JavaScript.

I get rid of the pseudocode to avoid confusion.

Sometimes new developers will get hung up with the syntax that it becomes difficult to move forward. Remember that syntax will come more naturally over time and there is no shame in referencing material for the correct syntax later on when coding.

6. Simplify and optimize your code

You’ve probably noticed by now that simplifying and optimizing are recurring themes.

“Simplicity is prerequisite for reliability.” — Edsger W. Dijkstra, Dutch computer scientist and early pioneer in many research areas of computing science

In this example, one way of optimizing it would be to filter out items from an array by returning a new array using filter . This way, we don’t have to define another variable evenNumbers because filter will return a new array with copies of elements that match the filter. This will not change the original array. We also don’t need to use a for loop with this approach. filter will go through each item, return either true , to have that element in the array, or false to skip it.

Simplifying and optimizing your code may require you to iterate a few times, identifying ways to further simplify and optimize code.

Here are some questions to keep in mind:

  • What are your goals for simplifying and optimizing? The goals will depend on your team’s style or your personal preference. Are you trying to condense the code as much as possible? Is the goal to make it the code more readable? If that’s the case, you may prefer taking that extra line to define the variable or compute something rather than trying to define and compute all in one line.
  • How else can you make the code more readable?
  • Are there any more extra steps you can take out?
  • Are there any variables or functions you ended up not even needing or using?
  • Are you repeating some steps a lot? See if you can define in another function.
  • Are there better ways to handle edge cases?
“Programs must be written for people to read, and only incidentally for machines to execute.” — Gerald Jay Sussman and Hal Abelson, Authors of “Structure and Interpretation of Computer Programs”

This step really should be throughout the process. Debugging throughout will help you catch any syntax errors or gaps in logic sooner rather than later. Take advantage of your Integrated Development Environment (IDE) and debugger. When I encounter bugs, I trace the code line-by-line to see if there was anything that did not go as expected. Here are some techniques I use:

  • Check the console to see what the error message says. Sometimes it’ll point out a line number I need to check. This gives me a rough idea of where to start, although the issue sometimes may not be at this line at all.
  • Comment out chunks or lines of code and output what I have so far to quickly see if the code is behaving how I expected. I can always uncomment the code as needed.
  • Use other sample data if there are scenarios I did not think of and see if the code will still work.
  • Save different versions of my file if I am trying out a completely different approach. I don’t want to lose any of my work if I end up wanting to revert back to it!
“The most effective debugging tool is still careful thought, coupled with judiciously placed print statements.” — Brian W. Kernighan, Computer Science Professor at Princeton University

8. Write useful comments

You may not always remember what every single line meant a month later. And someone else working on your code may not know either. That’s why it’s important to write useful comments to avoid problems and save time later on if you need to come back to it.

Stay away from comments such as:

// This is an array. Iterate through it.

// This is a variable

I try to write brief, high-level comments that help me understand what’s going on if it is not obvious. This comes in handy when I am working on more complex problems. It helps understand what a particular function is doing and why. Through the use of clear variable names, function names, and comments, you (and others) should be able to understand:

  • What is this code for?
  • What is it doing?

9. Get feedback through code reviews

Get feedback from your teammates, professors, and other developers. Check out Stack Overflow . See how others tackled the problem and learn from them. There are sometimes several ways to approach a problem. Find out what they are and you’ll get better and quicker at coming up with them yourself.

“No matter how slow you are writing clean code, you will always be slower if you make a mess.” — Uncle Bob Martin, Software Engineer and Co-author of the Agile Manifesto

10. Practice, practice, practice

Even experienced developers are always practicing and learning. If you get helpful feedback, implement it. Redo a problem or do similar problems. Keep pushing yourself. With each problem you solve, the better a developer you become. Celebrate each success and be sure to remember how far you’ve come. Remember that programming, like with anything, comes easier and more naturally with time.

“Take pride in how far you’ve come. Have faith in how far you can go. But don’t forget to enjoy the journey.” — Michael Josephson, Founder of Joseph and Edna Josephson Institute of Ethics

Thanks Gavin Stark

Valinda Chan

Written by Valinda Chan

Product & UX Design

More from Valinda Chan and codeburst

Must-Read Books for Software Developers

DataDrivenInvestor

Must-Read Books for Software Developers

60+ books on programming, computer science, algorithms and data structures, linear algebra, discrete mathematics, computer systems….

How To Create Horizontal Scrolling Containers

How To Create Horizontal Scrolling Containers

As a front end developer, more and more frequently i am given designs that include a horizontal scrolling component. this has become….

Top 50 Java Interview Questions for Beginners and Junior Developers

Top 50 Java Interview Questions for Beginners and Junior Developers

A list of frequently asked java questions and answers from programming job interviews of java developers of different experience..

7 things I wished designers did more of when working with developers

Muzli - Design Inspiration

7 things I wished designers did more of when working with developers

How designers can put in that extra effort to help ensure a great final product, recommended from medium.

Advice From a Software Engineer With 8 Years of Experience

Benoit Ruiz

Better Programming

Advice From a Software Engineer With 8 Years of Experience

Practical tips for those who want to advance in their careers.

I Built an App in 6 Hours that Makes $1,500/Mo

Artturi Jalli

I Built an App in 6 Hours that Makes $1,500/Mo

Copy my strategy.

steps of problem solving in programming

General Coding Knowledge

steps of problem solving in programming

Stories to Help You Grow as a Software Developer

steps of problem solving in programming

Coding & Development

steps of problem solving in programming

ChatGPT prompts

What Happens When You Start Reading Every Day

Sufyan Maan, M.Eng

ILLUMINATION

What Happens When You Start Reading Every Day

Think before you speak. read before you think. — fran lebowitz.

Common side effects of not drinking

Karolina Kozmana

Common side effects of not drinking

By rejecting alcohol, you reject something very human, an extra limb that we have collectively grown to deal with reality and with each….

Roadmap to Learn AI in 2024

Benedict Neo

bitgrit Data Science Publication

Roadmap to Learn AI in 2024

A free curriculum for hackers and programmers to learn ai.

A basic question in security Interview: How do you store passwords in the database?

A basic question in security Interview: How do you store passwords in the database?

Explained in 3 mins..

Text to speech

What Is Problem Solving? How Software Engineers Approach Complex Challenges

HackerRank AI Promotion

From debugging an existing system to designing an entirely new software application, a day in the life of a software engineer is filled with various challenges and complexities. The one skill that glues these disparate tasks together and makes them manageable? Problem solving . 

Throughout this blog post, we’ll explore why problem-solving skills are so critical for software engineers, delve into the techniques they use to address complex challenges, and discuss how hiring managers can identify these skills during the hiring process. 

What Is Problem Solving?

But what exactly is problem solving in the context of software engineering? How does it work, and why is it so important?

Problem solving, in the simplest terms, is the process of identifying a problem, analyzing it, and finding the most effective solution to overcome it. For software engineers, this process is deeply embedded in their daily workflow. It could be something as simple as figuring out why a piece of code isn’t working as expected, or something as complex as designing the architecture for a new software system. 

In a world where technology is evolving at a blistering pace, the complexity and volume of problems that software engineers face are also growing. As such, the ability to tackle these issues head-on and find innovative solutions is not only a handy skill — it’s a necessity. 

The Importance of Problem-Solving Skills for Software Engineers

Problem-solving isn’t just another ability that software engineers pull out of their toolkits when they encounter a bug or a system failure. It’s a constant, ongoing process that’s intrinsic to every aspect of their work. Let’s break down why this skill is so critical.

Driving Development Forward

Without problem solving, software development would hit a standstill. Every new feature, every optimization, and every bug fix is a problem that needs solving. Whether it’s a performance issue that needs diagnosing or a user interface that needs improving, the capacity to tackle and solve these problems is what keeps the wheels of development turning.

It’s estimated that 60% of software development lifecycle costs are related to maintenance tasks, including debugging and problem solving. This highlights how pivotal this skill is to the everyday functioning and advancement of software systems.

Innovation and Optimization

The importance of problem solving isn’t confined to reactive scenarios; it also plays a major role in proactive, innovative initiatives . Software engineers often need to think outside the box to come up with creative solutions, whether it’s optimizing an algorithm to run faster or designing a new feature to meet customer needs. These are all forms of problem solving.

Consider the development of the modern smartphone. It wasn’t born out of a pre-existing issue but was a solution to a problem people didn’t realize they had — a device that combined communication, entertainment, and productivity into one handheld tool.

Increasing Efficiency and Productivity

Good problem-solving skills can save a lot of time and resources. Effective problem-solvers are adept at dissecting an issue to understand its root cause, thus reducing the time spent on trial and error. This efficiency means projects move faster, releases happen sooner, and businesses stay ahead of their competition.

Improving Software Quality

Problem solving also plays a significant role in enhancing the quality of the end product. By tackling the root causes of bugs and system failures, software engineers can deliver reliable, high-performing software. This is critical because, according to the Consortium for Information and Software Quality, poor quality software in the U.S. in 2022 cost at least $2.41 trillion in operational issues, wasted developer time, and other related problems.

Problem-Solving Techniques in Software Engineering

So how do software engineers go about tackling these complex challenges? Let’s explore some of the key problem-solving techniques, theories, and processes they commonly use.

Decomposition

Breaking down a problem into smaller, manageable parts is one of the first steps in the problem-solving process. It’s like dealing with a complicated puzzle. You don’t try to solve it all at once. Instead, you separate the pieces, group them based on similarities, and then start working on the smaller sets. This method allows software engineers to handle complex issues without being overwhelmed and makes it easier to identify where things might be going wrong.

Abstraction

In the realm of software engineering, abstraction means focusing on the necessary information only and ignoring irrelevant details. It is a way of simplifying complex systems to make them easier to understand and manage. For instance, a software engineer might ignore the details of how a database works to focus on the information it holds and how to retrieve or modify that information.

Algorithmic Thinking

At its core, software engineering is about creating algorithms — step-by-step procedures to solve a problem or accomplish a goal. Algorithmic thinking involves conceiving and expressing these procedures clearly and accurately and viewing every problem through an algorithmic lens. A well-designed algorithm not only solves the problem at hand but also does so efficiently, saving computational resources.

Parallel Thinking

Parallel thinking is a structured process where team members think in the same direction at the same time, allowing for more organized discussion and collaboration. It’s an approach popularized by Edward de Bono with the “ Six Thinking Hats ” technique, where each “hat” represents a different style of thinking.

In the context of software engineering, parallel thinking can be highly effective for problem solving. For instance, when dealing with a complex issue, the team can use the “White Hat” to focus solely on the data and facts about the problem, then the “Black Hat” to consider potential problems with a proposed solution, and so on. This structured approach can lead to more comprehensive analysis and more effective solutions, and it ensures that everyone’s perspectives are considered.

This is the process of identifying and fixing errors in code . Debugging involves carefully reviewing the code, reproducing and analyzing the error, and then making necessary modifications to rectify the problem. It’s a key part of maintaining and improving software quality.

Testing and Validation

Testing is an essential part of problem solving in software engineering. Engineers use a variety of tests to verify that their code works as expected and to uncover any potential issues. These range from unit tests that check individual components of the code to integration tests that ensure the pieces work well together. Validation, on the other hand, ensures that the solution not only works but also fulfills the intended requirements and objectives.

Explore verified tech roles & skills.

The definitive directory of tech roles, backed by machine learning and skills intelligence.

Explore all roles

Evaluating Problem-Solving Skills

We’ve examined the importance of problem-solving in the work of a software engineer and explored various techniques software engineers employ to approach complex challenges. Now, let’s delve into how hiring teams can identify and evaluate problem-solving skills during the hiring process.

Recognizing Problem-Solving Skills in Candidates

How can you tell if a candidate is a good problem solver? Look for these indicators:

  • Previous Experience: A history of dealing with complex, challenging projects is often a good sign. Ask the candidate to discuss a difficult problem they faced in a previous role and how they solved it.
  • Problem-Solving Questions: During interviews, pose hypothetical scenarios or present real problems your company has faced. Ask candidates to explain how they would tackle these issues. You’re not just looking for a correct solution but the thought process that led them there.
  • Technical Tests: Coding challenges and other technical tests can provide insight into a candidate’s problem-solving abilities. Consider leveraging a platform for assessing these skills in a realistic, job-related context.

Assessing Problem-Solving Skills

Once you’ve identified potential problem solvers, here are a few ways you can assess their skills:

  • Solution Effectiveness: Did the candidate solve the problem? How efficient and effective is their solution?
  • Approach and Process: Go beyond whether or not they solved the problem and examine how they arrived at their solution. Did they break the problem down into manageable parts? Did they consider different perspectives and possibilities?
  • Communication: A good problem solver can explain their thought process clearly. Can the candidate effectively communicate how they arrived at their solution and why they chose it?
  • Adaptability: Problem-solving often involves a degree of trial and error. How does the candidate handle roadblocks? Do they adapt their approach based on new information or feedback?

Hiring managers play a crucial role in identifying and fostering problem-solving skills within their teams. By focusing on these abilities during the hiring process, companies can build teams that are more capable, innovative, and resilient.

Key Takeaways

As you can see, problem solving plays a pivotal role in software engineering. Far from being an occasional requirement, it is the lifeblood that drives development forward, catalyzes innovation, and delivers of quality software. 

By leveraging problem-solving techniques, software engineers employ a powerful suite of strategies to overcome complex challenges. But mastering these techniques isn’t simple feat. It requires a learning mindset, regular practice, collaboration, reflective thinking, resilience, and a commitment to staying updated with industry trends. 

For hiring managers and team leads, recognizing these skills and fostering a culture that values and nurtures problem solving is key. It’s this emphasis on problem solving that can differentiate an average team from a high-performing one and an ordinary product from an industry-leading one.

At the end of the day, software engineering is fundamentally about solving problems — problems that matter to businesses, to users, and to the wider society. And it’s the proficient problem solvers who stand at the forefront of this dynamic field, turning challenges into opportunities, and ideas into reality.

This article was written with the help of AI. Can you tell which parts?

Get started with HackerRank

Over 2,500 companies and 40% of developers worldwide use HackerRank to hire tech talent and sharpen their skills.

Recommended topics

  • Hire Developers
  • Problem Solving

Abstract, futuristic image generated by AI

Does a College Degree Still Matter for Developers in 2024?

Blog post cover

How to Solve Coding Problems: Step-by-Step Guide (2024)

Avatar of snappify

May 20, 2024 · 13 min read

Coding challenges are a common obstacle for many programmers, whether they are just starting or have years of experience.

In this complete guide, we will provide expert tips and strategies for effectively solving coding problems.

By following these valuable tips, you can confidently enhance your problem-solving skills and conquer even the most challenging coding tasks.

Let's get started.

Read the Problem Statement Carefully

Read the Problem Statement Carefully

Identify key constraints

One imperative step in solving coding problems is identifying the key constraints in the problem statement. These constraints define the boundaries within which your solution must operate and can greatly influence your approach.

Note important variables

Carefully note down important variables mentioned in the problem statement as they often hold crucial information for solving the problem efficiently.

Understanding the significance of these variables can guide you toward the right solution approach.

Remember to consider any implicit variables that might affect your solution but are not explicitly mentioned in the problem statement.

Attention to all variables will ensure a more comprehensive understanding of the problem.

Tip:  Here, you can learn about key  programming definitions and terms

Create your next presentation

snappify will help you to create stunning presentations and videos.

This video was created using snappify 🤩

Break Down Complexity

Break Down Complexity

Divide into smaller Tasks

You'll find that breaking down a complex coding problem into smaller tasks makes it more manageable.

Start by identifying the different components of the problem and breaking them down into smaller subproblems. This approach will help you tackle each subproblem individually and eventually solve the larger problem.

Focus on one task

The key to successfully breaking down a complex coding problem is to focus on one task at a time.

Concentrating all your efforts on solving one specific subproblem can help you avoid feeling overwhelmed by the complexity of the overall task.

This focused approach will improve your problem-solving skills and allow you to make steady progress toward the final solution.

When focusing on one task, setting clear goals and objectives for that specific subproblem is vital. It will help you stay on track and prevent distractions derailing your problem-solving process.

By dedicating your full attention and energy to each task, you can efficiently work through the complexities of the coding problem and find an effective solution.

Tip:  The  Feynman learning technique  is the best solution for learning how to break down complex concepts.

Research and Learn

Research and Learn

Study similar problems

Research shows that one of the best strategies to solve coding problems easily is to study similar problems.

By analyzing how others have approached and solved comparable issues, you can gain valuable insights and techniques to apply to your challenges.

Learn new concepts

Learning new concepts is imperative for continuous improvement in coding.

By staying updated with the latest technologies, algorithms, and best practices, you can enhance your problem-solving skills and broaden your understanding of different coding techniques.

Any aspiring coder should regularly explore new concepts through online courses, tutorials, and coding challenges.

This proactive approach helps solve current problems more effectively and prepares you for future challenges in the ever-evolving tech industry.

Tip:  The fastest way to learn any new concept is to share what you learn. For example, you can learn a piece of code and then use  code sharing tools  to share your knowledge with the audience.

Write Pseudocode First

Write Pseudocode First

Plan out Algorithm Steps

For effective problem-solving, it is crucial to plan out the steps of your algorithm before writing actual code.

Pseudocode helps break down the problem into smaller, manageable steps, making it easier to implement the solution in the chosen programming language.

Visualize solution flow

While writing pseudocode, visualize how the solution will flow from one step to another.

This visualization helps in understanding the logic of the algorithm and can highlight any potential issues or optimizations that can be made before writing actual code.

For instance, if you are working on a sorting algorithm, visualizing the flow can help you determine the most efficient way to arrange the elements and identify any redundant steps that you can eliminate to improve performance.

Start with Simple

Start with Simple

Implement basic solution

Unlike complex problems, coding problems are best tackled with a straightforward approach.

Begin by implementing a basic solution that may not be the most efficient but solves the problem correctly.

This helps in understanding the problem better and getting a working solution.

Refine as needed

Implementing a basic solution is just the beginning.

As you progress, refine your code by optimizing it for performance, readability, and scalability.

Refactoring code to improve efficiency and incorporating best practices will boost your solution to the next level.

A key strategy for refining your code is to analyze its complexity and identify areas for optimization. This may involve revisiting your algorithm choices and data structures or breaking down the problem into smaller, manageable parts.

By continuously refining your solution, you improve your coding skills and enhance the quality of your code.

Use Online Resources

Use Online Resources

Leverage coding communities

Despite the various challenges of coding problems, the process becomes easier when you tap into the wealth of knowledge available in coding communities.

These online platforms, such as Stack Overflow and GitHub, offer a supportive environment where you can seek solutions, ask questions, and learn from experienced programmers.

Consult online tutorials

These resources provide step-by-step guidance on various programming concepts and problem-solving techniques, making grasping complex algorithms and data structures easier.

The abundance of online tutorials ranges from beginner to advanced, and they are fit for programmers of all proficiency levels.

By consulting these tutorials, you can enhance your understanding of coding principles and develop effective strategies for solving various coding problems.

Any aspiring coder should take advantage of the vast array of online resources that can facilitate the process of solving coding problems.

By leveraging coding communities, consulting online tutorials, and exploring other online platforms, you can quickly sharpen your problem-solving skills and become a more proficient programmer.

Tip:  Resources like YouTube and Udemy are great ways. But you can also read the  best development books  to enhance your coding skills further.

Debug Thoroughly

Debug Thoroughly

Identify common mistakes

Unlike overlooking small errors, identifying common mistakes is crucial in debugging code efficiently.

Any coder should be aware of recurring issues like:

  • Syntax Errors
  • Logical mistakes
  • Incorrect variable usage

By recognizing these patterns, programmers can initiate debugging and write cleaner code.

Test edge cases

Any comprehensive debugging strategy should include testing edge cases to ensure code reliability and robustness.

By intentionally pushing the boundaries of input values or conditions, developers can uncover potential mistakes that might go unnoticed during regular testing.

This practice helps programmers anticipate and address unexpected scenarios, leading to more resilient code.

Testing edge cases involves evaluating the extremes of input data or conditions to verify the code's behavior under challenging circumstances.

By examining how the program handles unusual or extreme values, developers can identify vulnerabilities or inefficiencies that may occur in real-world usage.

Practice Regularly

Practice Regularly

Build problem-solving muscle

Your coding skills are like a muscle that needs regular exercise to strengthen. Make a habit of solving coding problems daily to enhance your problem-solving abilities.

Develop coding instincts

Build a strong intuition for coding by practicing regularly.

As you solve more problems, you'll notice patterns and common strategies that can help you tackle new problems more efficiently.

Developing coding instincts involves understanding different approaches to problem-solving and knowing when to apply them. This initiative will guide you in choosing the most effective solutions and optimizing your code for better performance.

Review and Refine

Review and Refine

Analyze solution efficiency

Unlike simply finding a solution, it is imperative to analyze its efficiency.

Evaluate the time complexity, space complexity, and overall performance of the code.

This step will help you understand how the code will perform with larger inputs and whether there are any bottlenecks that need to be addressed.

Optimize code quality

Coding problems are not just about finding a solution but also about writing clean and efficient code.

Pay attention to coding standards, readability, and best practices.

Refactor the code to make it more concise, understandable, and maintainable. This step is crucial in ensuring that your code is not only functional but also of high quality.

You can use tools like linters and code formatters to check and improve your code's quality automatically.

These tools can help you catch potential errors, enforce coding standards, and enhance the overall readability of your codebase.

By optimizing your code quality, you can make it easier for yourself and others to understand and work with the code in the future.

Tip:  You can use a  code review checklist  to optimize code efficiency quickly.

Learn from Others

Learn from Others

Study open-source code

Study open-source code to truly enhance your coding skills.

By studying the work of experienced developers, you can gain insight into different perspectives, problem-solving techniques, and coding styles.

This exposure can broaden your knowledge and inspire innovative solutions to coding problems.

Learn from mentors

Some of the most effective learning experiences come from mentors who can provide guidance, feedback, and real-world insights.

Connecting with experienced professionals in the field can offer valuable advice, help you navigate challenges, and accelerate your learning process.

Learn from mentors who have expertise in your specific area of interest.

Their guidance can help you grasp complex concepts, avoid common pitfalls, and stay updated on industry trends.

Building a strong mentorship relationship can significantly impact your coding journey and foster professional growth.

Stay Calm and Patient

Stay Calm and Patient

Manage problem-solving stress

After encountering a challenging coding problem, managing the stress that comes with it is imperative.

Take deep breaths, step back, and remind yourself that feeling stuck is okay.

Keeping a clear mind will help you approach the problem more effectively.

Take breaks when needed

If you find yourself hitting a wall and getting frustrated, it's time to take a break.

Stepping away from the problem for a few minutes or even an hour can improve your mental clarity.

Some fresh air or a quick walk can help reset your mind and improve focus when you return to the task.

When stress builds up, it can blur your thinking and make problem-solving even more challenging.

Taking breaks gives you a chance to relax and allows your brain to subconsciously work on the problem in the background, often leading to new insights and solutions.

Identify Patterns

Identify Patterns

Recognize common patterns

One vital skill in solving coding problems is recognizing common patterns.

By identifying recurring themes or structures in the problem you're trying to solve, you can apply similar solutions that have worked in the past. It can help simplify your problem-solving process and lead to more efficient coding.

Apply pattern-based solutions

To effectively apply pattern-based solutions, you need to understand different types of patterns commonly found in coding problems.

These patterns can include algorithms like sliding windows, two-pointers, or depth-first search.

By leveraging these patterns, you can quickly develop solutions that have been proven to work for similar problems.

Tip:  You can explore different  development frameworks  to identify common patterns.

Draw Diagrams

Draw Diagrams

Visualize problem structure

When faced with a complex coding problem, start by visualizing its structure.

Use diagrams to represent different components, their relationships, and data flow. This visual representation can clarify the problem and help you identify key areas to focus on.

Illustrate solution flow

While solving coding problems, illustrating the solution flow through diagrams can facilitate the problem-solving process.

Create a step-by-step flowchart or sequence diagram to map the logic and algorithm.

This visual aid can guide you through the implementation phase and help you identify potential errors or optimizations in the solution.

Diagrams can also serve as documentation for your code, making it easier for others to understand your thought process and approach.

By incorporating visual elements into your problem-solving strategies, you can enhance your efficiency and accuracy in coding.

Collaborate with Peers

Collaborate with Peers

Work with coding partners

For an effective problem-solving strategy, consider working with coding partners.

Collaborating with peers can help you bounce ideas off each other, share different approaches, and collectively develop innovative solutions.

By leveraging your peers diverse skills and perspectives, you can tackle coding problems more efficiently and effectively.

Learn from peer feedback

Even the most experienced coders can benefit from constructive feedback from their peers.

Peer feedback can provide valuable insights into alternative solutions, code optimization techniques, and potential pitfalls to avoid.

You can continuously improve your problem-solving skills and expand your coding knowledge by actively seeking and incorporating feedback from your coding peers.

Work with your coding partners to brainstorm ideas, discuss different approaches, and troubleshoot any challenges you encounter.

Creating a collaborative environment with your peers can enhance your problem-solving abilities and accelerate your learning process.

Final Words

Mastering the key skills mentioned above will help you solve coding problems more easily and efficiently.

Buffing your problem-solving skills, staying organized, and utilizing various techniques such as pseudocoding and debugging can help you tackle coding challenges with confidence and precision.

Keep practicing and implementing these strategies to enhance your problem-solving abilities and become a more skilled coder.

Why is code optimization important in the problem-solving process?

Code optimization is important in the problem-solving process because it improves the code's performance and efficiency. Optimized code runs faster, requires less memory, and performs better with large input sizes. Optimization reduces the code's time and space complexity and ensures that it meets performance requirements.

Why is testing your code with different test cases important in coding problem-solving?

Testing your code with different test cases helps ensure your solution works correctly for various scenarios. It also helps identify edge cases, errors, and potential bugs in the code. Thorough testing enhances the reliability and accuracy of your code.

Share Article

DEV Community

DEV Community

Christopher Glikpo

Posted on Jul 27, 2021

5 Steps to Solving Programming Problems

We solve issues all the time as people, and developers are no different. Problem-solving-focused classes aren't particularly popular or frequent, and many developers prefer to study tools, languages, and frameworks over learning how to think like a problem solver or a programmer.

Problem solving is a programmer's bread and butter, and while everyone has their own technique, I've discovered five methods that will most certainly help you not only solve issues faster and more efficiently.

What is Problem Solving?

Problem-solving can mean different things for different people or situations so it is good to clarify what this article means when “problem-solving” is mentioned.

When you bring your broken automobile to the shop, they may decide to fix what's broken, replace the broken part, or offer you the option of purchasing a new car. Even though all of these alternatives appear to be “solutions,” only the first one truly addresses the issue. Everything else is an attempt to avoid dealing with the issue.

You solve a problem when given a set of constraints and having to follow some rules you come up with a solution that meets all the constraints and does not break the rules. As programmers, we write a program, a set of instructions that solves the problem.

To Code is different than To Solve Problem

Anyone who invests the effort to learn how to code will eventually be able to program. It's similar to learning a new language to learn to code. It is the ability to provide instructions for a computer to follow using a language that can be understood or compiled by a computer.

Problem-solving is a separate skill set, and we are inherently adept at it as humans. I mean, by solving problem after problem, we constructed the world around us. Connecting these two skill sets is something that many developers struggle with. Solving programming issues improves your ability to solve real-world problems, and if you're excellent at them, programming may come easy to you.

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

image

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 .

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
  • What will that array contain? One or more numbers
  • What are the data types of the elements in the array? Numbers
  • What is the goal of this function? What am I returning at the end of this function? The goal is to take all the even numbers and return them in an array. If there are no even numbers, return an empty array.

2. Manually solve the problem with at least three sets of sample data.

Take out a piece of paper and work through the problem manually. Think of at least three sets of sample data you can use. Consider corner and edge cases as well.

Corner case : a problem or situation that occurs outside of normal operating parameters, specifically when multiple environmental variables or conditions are simultaneously at extreme levels, even though each parameter is within the specified range for that parameter. Edge case : problem or situation that occurs only at an extreme (maximum or minimum) operating parameter

For example, here are some sample data sets to use:

When you are first starting out, it is easy to gloss over the steps.

Because your brain is already accustomed with even numbers, you may easily glance at a sample set of data and pluck out numbers like 2 , 4 , 6 , and so on in the array without realizing it. If you're having trouble, consider using massive quantities of data, which will overcome your brain's natural ability to answer the problem simply by looking at it.That helps you work through the real algorithm.

Let’s go through the first array [1]

  • Look at the only element in the array [1]
  • Decide if it is even. It is not
  • Notice that there are no more elements in this array
  • Determine there are no even numbers in this provided array
  • Return an empty array

Let’s go through the array [1, 2] 1.Look at the first element in array [1, 2]

  • Look at the next element in the array
  • Decide if it is even. It is even
  • Make an array evenNumbers and add 2 to this array
  • Return the array evenNumbers which is [2]

I go through this a few more times. Notice how the steps I wrote down for [1] varies slightly from [1, 2] . That is why I try to go through a couple of different sets. I have some sets with just one element, some with floats instead of just integers, some with multiple digits in an element, and some with negatives just to be safe.

3. Simplify and optimize your steps

Look for patterns and see if there’s anything you can generalize. See if you can reduce any steps or if you are repeating any steps.

1.Create a function selectEvenNumbers

  • Create a new empty array evenNumbers where I store even numbers, if any
  • Go through each element in the array [1, 2]
  • Find the first element
  • Decide if it is even by seeing if it is divisible by 2. If it is even, I add that to evenNumbers
  • Find the next element
  • Repeat step #4
  • Repeat step #5 and #4 until there are no more elements in this array
  • Return the array evenNumbers , regardless of whether it has anything in it

This approach may remind you of Mathematical Induction in that you: 1.Show it is true for n = 1, n = 2, ...

2.Suppose it is true for n = k

3.Prove it is true for n = k + 1

4.Write pseudocode

Even once you've figured out the main processes, developing pseudocode that you can translate into code can help you define your code's structure and make coding a lot easier. Line by line, write pseudocode. You may do this on paper or in your code editor as comments. I recommend doing it on paper if you're just starting off and find blank displays intimidating or distracting.

Pseudocode generally does not actually have specific rules in particular but sometimes, I might end up including some syntax from a language just because I am familiar enough with an aspect of the programming language. Don’t get caught up with the syntax. Focus on the logic and steps.

Let's think about the steps needed to write a function that returns a number's squared value.

Now we know exactly what our code is supposed to do, we have one more step.

5. Translate pseudocode into code

When you have your pseudocode ready, translate each line into real code in the language you are working on. We will use JavaScript for this example. If you wrote it out on paper, type this up as comments in your code editor. Then replace each line in your pseudocode. Lets use our square example (very simple for demonstration purposes):

Optimize your code:

If you've reached this point, thank you very much. I hope that this tutorial has been helpful for you and I'll see you all in the next.

Buy me a coffee

If you want to learn more about Web Development don't forget to follow me on Youtube!

Top comments (0)

pic

Templates let you quickly answer FAQs or store snippets for re-use.

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink .

Hide child comments as well

For further actions, you may consider blocking this person and/or reporting abuse

milasuperstar profile image

🔧Top Open Source AI Web Scrapers to Fire Up Your Market Research🔥

Mila Wu - May 27

ettalibi02assia profile image

Building a Secured User Authentication System with PHP, MySQL, PDO and hashed password

Assia Ettalibi - May 14

ramgoel profile image

Multiple Environments in Frontend Applications

Ram Goel - May 27

mvaja13 profile image

createBrowserRouter A step up from Switch

Gautam Vaja - May 18

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Problem Solving

Foundations course, introduction.

Before we start digging into some pretty nifty JavaScript, we need to begin talking about problem solving : the most important skill a developer needs.

Problem solving is the core thing software developers do. The programming languages and tools they use are secondary to this fundamental skill.

From his book, “Think Like a Programmer” , V. Anton Spraul defines problem solving in programming as:

Problem solving is writing an original program that performs a particular set of tasks and meets all stated constraints.

The set of tasks can range from solving small coding exercises all the way up to building a social network site like Facebook or a search engine like Google. Each problem has its own set of constraints, for example, high performance and scalability may not matter too much in a coding exercise but it will be vital in apps like Google that need to service billions of search queries each day.

New programmers often find problem solving the hardest skill to build. It’s not uncommon for budding programmers to breeze through learning syntax and programming concepts, yet when trying to code something on their own, they find themselves staring blankly at their text editor not knowing where to start.

The best way to improve your problem solving ability is by building experience by making lots and lots of programs. The more practice you have the better you’ll be prepared to solve real world problems.

In this lesson we will walk through a few techniques that can be used to help with the problem solving process.

Lesson overview

This section contains a general overview of topics that you will learn in this lesson.

  • Explain the three steps in the problem solving process.
  • Explain what pseudocode is and be able to use it to solve problems.
  • Be able to break a problem down into subproblems.

Understand the problem

The first step to solving a problem is understanding exactly what the problem is. If you don’t understand the problem, you won’t know when you’ve successfully solved it and may waste a lot of time on a wrong solution .

To gain clarity and understanding of the problem, write it down on paper, reword it in plain English until it makes sense to you, and draw diagrams if that helps. When you can explain the problem to someone else in plain English, you understand it.

Now that you know what you’re aiming to solve, don’t jump into coding just yet. It’s time to plan out how you’re going to solve it first. Some of the questions you should answer at this stage of the process:

  • Does your program have a user interface? What will it look like? What functionality will the interface have? Sketch this out on paper.
  • What inputs will your program have? Will the user enter data or will you get input from somewhere else?
  • What’s the desired output?
  • Given your inputs, what are the steps necessary to return the desired output?

The last question is where you will write out an algorithm to solve the problem. You can think of an algorithm as a recipe for solving a particular problem. It defines the steps that need to be taken by the computer to solve a problem in pseudocode.

Pseudocode is writing out the logic for your program in natural language instead of code. It helps you slow down and think through the steps your program will have to go through to solve the problem.

Here’s an example of what the pseudocode for a program that prints all numbers up to an inputted number might look like:

This is a basic program to demonstrate how pseudocode looks. There will be more examples of pseudocode included in the assignments.

Divide and conquer

From your planning, you should have identified some subproblems of the big problem you’re solving. Each of the steps in the algorithm we wrote out in the last section are subproblems. Pick the smallest or simplest one and start there with coding.

It’s important to remember that you might not know all the steps that you might need up front, so your algorithm may be incomplete -— this is fine. Getting started with and solving one of the subproblems you have identified in the planning stage often reveals the next subproblem you can work on. Or, if you already know the next subproblem, it’s often simpler with the first subproblem solved.

Many beginners try to solve the big problem in one go. Don’t do this . If the problem is sufficiently complex, you’ll get yourself tied in knots and make life a lot harder for yourself. Decomposing problems into smaller and easier to solve subproblems is a much better approach. Decomposition is the main way to deal with complexity, making problems easier and more approachable to solve and understand.

In short, break the big problem down and solve each of the smaller problems until you’ve solved the big problem.

Solving Fizz Buzz

To demonstrate this workflow in action, let’s solve Fizz Buzz

Understanding the problem

Write a program that takes a user’s input and prints the numbers from one to the number the user entered. However, for multiples of three print Fizz instead of the number and for the multiples of five print Buzz . For numbers which are multiples of both three and five print FizzBuzz .

This is the big picture problem we will be solving. But we can always make it clearer by rewording it.

Write a program that allows the user to enter a number, print each number between one and the number the user entered, but for numbers that divide by 3 without a remainder print Fizz instead. For numbers that divide by 5 without a remainder print Buzz and finally for numbers that divide by both 3 and 5 without a remainder print FizzBuzz .

Does your program have an interface? What will it look like? Our FizzBuzz solution will be a browser console program, so we don’t need an interface. The only user interaction will be allowing users to enter a number.

What inputs will your program have? Will the user enter data or will you get input from somewhere else? The user will enter a number from a prompt (popup box).

What’s the desired output? The desired output is a list of numbers from 1 to the number the user entered. But each number that is divisible by 3 will output Fizz , each number that is divisible by 5 will output Buzz and each number that is divisible by both 3 and 5 will output FizzBuzz .

Writing the pseudocode

What are the steps necessary to return the desired output? Here is an algorithm in pseudocode for this problem:

Dividing and conquering

As we can see from the algorithm we developed, the first subproblem we can solve is getting input from the user. So let’s start there and verify it works by printing the entered number.

With JavaScript, we’ll use the “prompt” method.

The above code should create a little popup box that asks the user for a number. The input we get back will be stored in our variable answer .

We wrapped the prompt call in a parseInt function so that a number is returned from the user’s input.

With that done, let’s move on to the next subproblem: “Loop from 1 to the entered number”. There are many ways to do this in JavaScript. One of the common ways - that you actually see in many other languages like Java, C++, and Ruby - is with the for loop :

If you haven’t seen this before and it looks strange, it’s actually straightforward. We declare a variable i and assign it 1: the initial value of the variable i in our loop. The second clause, i <= answer is our condition. We want to loop until i is greater than answer . The third clause, i++ , tells our loop to increment i by 1 every iteration. As a result, if the user inputs 10, this loop would print numbers 1 - 10 to the console.

Most of the time, programmers find themselves looping from 0. Due to the needs of our program, we’re starting from 1

With that working, let’s move on to the next problem: If the current number is divisible by 3, then print Fizz .

We are using the modulus operator ( % ) here to divide the current number by three. If you recall from a previous lesson, the modulus operator returns the remainder of a division. So if a remainder of 0 is returned from the division, it means the current number is divisible by 3.

After this change the program will now output this when you run it and the user inputs 10:

The program is starting to take shape. The final few subproblems should be easy to solve as the basic structure is in place and they are just different variations of the condition we’ve already got in place. Let’s tackle the next one: If the current number is divisible by 5 then print Buzz .

When you run the program now, you should see this output if the user inputs 10:

We have one more subproblem to solve to complete the program: If the current number is divisible by 3 and 5 then print FizzBuzz .

We’ve had to move the conditionals around a little to get it to work. The first condition now checks if i is divisible by 3 and 5 instead of checking if i is just divisible by 3. We’ve had to do this because if we kept it the way it was, it would run the first condition if (i % 3 === 0) , so that if i was divisible by 3, it would print Fizz and then move on to the next number in the iteration, even if i was divisible by 5 as well.

With the condition if (i % 3 === 0 && i % 5 === 0) coming first, we check that i is divisible by both 3 and 5 before moving on to check if it is divisible by 3 or 5 individually in the else if conditions.

The program is now complete! If you run it now you should get this output when the user inputs 20:

  • Read How to Think Like a Programmer - Lessons in Problem Solving by Richard Reis.
  • Watch How to Begin Thinking Like a Programmer by Coding Tech. It’s an hour long but packed full of information and definitely worth your time watching.
  • Read this Pseudocode: What It Is and How to Write It article from Built In.

Knowledge check

The following questions are an opportunity to reflect on key topics in this lesson. If you can’t answer a question, click on it to review the material, but keep in mind you are not expected to memorize or master this knowledge.

  • What are the three stages in the problem solving process?
  • Why is it important to clearly understand the problem first?
  • What can you do to help get a clearer understanding of the problem?
  • What are some of the things you should do in the planning stage of the problem solving process?
  • What is an algorithm?
  • What is pseudocode?
  • What are the advantages of breaking a problem down and solving the smaller problems?

Additional resources

This section contains helpful links to related content. It isn’t required, so consider it supplemental.

  • Read the first chapter in Think Like a Programmer: An Introduction to Creative Problem Solving ( not free ). This book’s examples are in C++, but you will understand everything since the main idea of the book is to teach programmers to better solve problems. It’s an amazing book and worth every penny. It will make you a better programmer.
  • Watch this video on repetitive programming techniques .
  • Watch Jonathan Blow on solving hard problems where he gives sage advice on how to approach problem solving in software projects.

Support us!

The odin project is funded by the community. join us in empowering learners around the globe by supporting the odin project.

Tutorial Playlist

Programming tutorial, your guide to the best backend languages for 2024, an ultimate guide that helps you to start learn coding 2024, what is backend development: the ultimate guide for beginners, all you need to know for choosing the first programming language to learn, here’s all you need to know about coding, decoding, and reasoning with examples, understanding what is xml: the best guide to xml and its concepts., an ultimate guide to learn the importance of low-code and no-code development, top frontend languages that you should know about, top 75+ frontend developer interview questions and answers, the ultimate guide to learn typescript generics, the most comprehensive guide for beginners to know ‘what is typescript’.

The Ultimate Guide on Introduction to Competitive Programming

Top 60+ TCS NQT Interview Questions and Answers for 2024

Most commonly asked logical reasoning questions in an aptitude test, everything you need to know about advanced typescript concepts, an absolute guide to build c hello world program, a one-stop solution guide to learn how to create a game in unity, what is nat significance of nat for translating ip addresses in the network model, data science vs software engineering: key differences, a real-time chat application typescript project using node.js as a server, what is raspberry pi here’s the best guide to get started, what is arduino here’s the best beginners guide to get started, arduino vs. raspberry pi: which is the better board, the perfect guide for all you need to learn about mean stack, software developer resume: a comprehensive guide, here’s everything all you need to know about the programming roadmap, an ultimate guide that helps you to develop and improve problem solving in programming, the top 10 awesome arduino projects of all time, roles of product managers, pyspark rdd: everything you need to know about pyspark rdd, wipro interview questions and answers that you should know before going for an interview, how to use typescript with nodejs: the ultimate guide, what is rust programming language why is it so popular, software terminologies, an ultimate guide that helps you to develop and improve problem solving in programming.

Lesson 27 of 34 By Hemant Deshpande

An Ultimate Guide That Helps You to Develop and Improve Problem Solving in Programming

Table of Contents

Coding and Programming skills hold a significant and critical role in implementing and developing various technologies and software. They add more value to the future and development. These programming and coding skills are essential for every person to improve problem solving skills. So, we brought you this article to help you learn and know the importance of these skills in the future. 

Want a Top Software Development Job? Start Here!

Want a Top Software Development Job? Start Here!

Topics covered in this problem solving in programming article are:

  • What is Problem Solving in Programming? 
  • Problem Solving skills in Programming
  • How does it impact your career ?
  • Steps involved in Problem Solving
  • Steps to improve Problem Solving in programming

What is Problem Solving in Programming?

Computers are used to solve various problems in day-to-day life. Problem Solving is an essential skill that helps to solve problems in programming. There are specific steps to be carried out to solve problems in computer programming, and the success depends on how correctly and precisely we define a problem. This involves designing, identifying and implementing problems using certain steps to develop a computer.

When we know what exactly problem solving in programming is, let us learn how it impacts your career growth.

How Does It Impact Your Career?

Many companies look for candidates with excellent problem solving skills. These skills help people manage the work and make candidates put more effort into the work, which results in finding solutions for complex problems in unexpected situations. These skills also help to identify quick solutions when they arise and are identified. 

People with great problem solving skills also possess more thinking and analytical skills, which makes them much more successful and confident in their career and able to work in any kind of environment. 

The above section gives you an idea of how problem solving in programming impacts your career and growth. Now, let's understand what problem solving skills mean.

Problem Solving Skills in Programming

Solving a question that is related to computers is more complicated than finding the solutions for other questions. It requires excellent knowledge and much thinking power. Problem solving in programming skills is much needed for a person and holds a major advantage. For every question, there are specific steps to be followed to get a perfect solution. By using those steps, it is possible to find a solution quickly.

The above section is covered with an explanation of problem solving in programming skills. Now let's learn some steps involved in problem solving.

Steps Involved in Problem Solving

Before being ready to solve a problem, there are some steps and procedures to be followed to find the solution. Let's have a look at them in this problem solving in programming article.

Basically, they are divided into four categories:

  • Analysing the problem
  • Developing the algorithm
  • Testing and debugging

Analysing the Problem

Every problem has a perfect solution; before we are ready to solve a problem, we must look over the question and understand it. When we know the question, it is easy to find the solution for it. If we are not ready with what we have to solve, then we end up with the question and cannot find the answer as expected. By analysing it, we can figure out the outputs and inputs to be carried out. Thus, when we analyse and are ready with the list, it is easy and helps us find the solution easily. 

Developing the Algorithm

It is required to decide a solution before writing a program. The procedure of representing the solution  in a natural language called an algorithm. We must design, develop and decide the final approach after a number of trials and errors, before actually writing the final code on an algorithm before we write the code. It captures and refines all the aspects of the desired solution.

Once we finalise the algorithm, we must convert the decided algorithm into a code or program using a dedicated programming language that is understandable by the computer to find a desired solution. In this stage, a wide variety of programming languages are used to convert the algorithm into code. 

Testing and Debugging

The designed and developed program undergoes several rigorous tests based on various real-time parameters and the program undergoes various levels of simulations. It must meet the user's requirements, which have to respond with the required time. It should generate all expected outputs to all the possible inputs. The program should also undergo bug fixing and all possible exception handling. If it fails to show the possible results, it should be checked for logical errors.

Industries follow some testing methods like system testing, component testing and acceptance testing while developing complex applications. The errors identified while testing are debugged or rectified and tested again until all errors are removed from the program.

The steps mentioned above are involved in problem solving in programming. Now let's see some more detailed information about the steps to improve problem solving in programming.

Steps to Improve Problem Solving in Programming

Right mindset.

The way to approach problems is the key to improving the skills. To find a solution, a positive mindset helps to solve problems quickly. If you think something is impossible, then it is hard to achieve. When you feel free and focus with a positive attitude, even complex problems will have a perfect solution.

Making Right Decisions

When we need to solve a problem, we must be clear with the solution. The perfect solution helps to get success in a shorter period. Making the right decisions in the right situation helps to find the perfect solution quickly and efficiently. These skills also help to get more command over the subject.

Keeping Ideas on Track

Ideas always help much in improving the skills; they also help to gain more knowledge and more command over things. In problem solving situations, these ideas help much and help to develop more skills. Give opportunities for the mind and keep on noting the ideas.

Learning from Feedbacks

A crucial part of learning is from the feedback. Mistakes help you to gain more knowledge and have much growth. When you have a solution for a problem, go for the feedback from the experienced or the professionals. It helps you get success within a shorter period and enables you to find other solutions easily.

Asking Questions

Questions are an incredible part of life. While searching for solutions, there are a lot of questions that arise in our minds. Once you know the question correctly, then you are able to find answers quickly. In coding or programming, we must have a clear idea about the problem. Then, you can find the perfect solution for it. Raising questions can help to understand the problem.

These are a few reasons and tips to improve problem solving in programming skills. Now let's see some major benefits in this article.

  • Problem solving in programming skills helps to gain more knowledge over coding and programming, which is a major benefit.
  • These problem solving skills also help to develop more skills in a person and build a promising career.
  • These skills also help to find the solutions for critical and complex problems in a perfect way.
  • Learning and developing problem solving in programming helps in building a good foundation.
  • Most of the companies are looking for people with good problem solving skills, and these play an important role when it comes to job opportunities 
Don't miss out on the opportunity to become a Certified Professional with Simplilearn's Post Graduate Program in Full Stack Web Development . Enroll Today!

Problem solving in programming skills is important in this modern world; these skills build a great career and hold a great advantage. This article on problem solving in programming provides you with an idea of how it plays a massive role in the present world. In this problem solving in programming article, the skills and the ways to improve more command on problem solving in programming are mentioned and explained in a proper way.

If you are looking to advance in your career. Simplilearn provides training and certification courses on various programming languages - Python , Java , Javascript , and many more. Check out our Post Graduate Program in Full Stack Web Development course that will help you excel in your career.

If you have any questions for us on the problem solving in programming article. Do let us know in the comments section below; we have our experts answer it right away.

Find our Full Stack Developer - MERN Stack Online Bootcamp in top cities:

About the author.

Hemant Deshpande

Hemant Deshpande, PMP has more than 17 years of experience working for various global MNC's. He has more than 10 years of experience in managing large transformation programs for Fortune 500 clients across verticals such as Banking, Finance, Insurance, Healthcare, Telecom and others. During his career he has worked across the geographies - North America, Europe, Middle East, and Asia Pacific. Hemant is an internationally Certified Executive Coach (CCA/ICF Approved) working with corporate leaders. He also provides Management Consulting and Training services. He is passionate about writing and regularly blogs and writes content for top websites. His motto in life - Making a positive difference.

Recommended Resources

Your One-Stop Solution to Understand Coin Change Problem

Your One-Stop Solution to Understand Coin Change Problem

Combating the Global Talent Shortage Through Skill Development Programs

Combating the Global Talent Shortage Through Skill Development Programs

What Is Problem Solving? Steps, Techniques, and Best Practices Explained

What Is Problem Solving? Steps, Techniques, and Best Practices Explained

One Stop Solution to All the Dynamic Programming Problems

One Stop Solution to All the Dynamic Programming Problems

The Ultimate Guide on Introduction to Competitive Programming

The Ultimate Guide to Top Front End and Back End Programming Languages for 2021

  • PMP, PMI, PMBOK, CAPM, PgMP, PfMP, ACP, PBA, RMP, SP, and OPM3 are registered marks of the Project Management Institute, Inc.

UNIT 1: How to Think Like an Engineer

Learning objectives.

  • Explain what we mean by “Computational Thinking”.
  • Describe the problem being solved in a computational algorithm.
  • Explain the process for generating computational algorithms.
  • Generate and test algorithms to solve computational problems.
  • Evaluate computational algorithms for exactness, correctness, termination, generalizability and understandability.
  • Explain the role of programming in the field of Informatics.

Introduction

The goal of this book is to teach you to solve computational problems and to think like an engineer. Computational problems are problems that can be solved by the use of computations (a computation is what you do when you calculate something). Engineers are people who solve problems – they invent, design, analyze, build and test “things” to fulfill objectives and requirements. The single most important skill for you to learn is problem solving. Problem solving means the ability to formulate problems, think creatively about solutions, and express a solution clearly and accurately. As it turns out, the process of learning to program is an excellent opportunity to practice problem-solving skills.

This book strives to prepare you to write well-designed computer programs that solve interesting problems involving data.

Computational Thinking

computational thinking chart

Figure 1: “The seven components to computational thinking”(www.ignitemyfutureinschool.org/about)

Computational Thinking is the thought processes involved in understanding a problem and expressing its solution in a way that a computer can effectively carry out. Computational thinking involves solving problems, designing systems, and understanding human behavior (e.g. what the user needs or wants) – thinking like an engineer. Computational thinking is a fundamental skill for everyone, not just for programmers because computational thinking is what comes before any computing technology. [1]

Computer science is the study of computation — what can be computed and how to compute it whereas computational thinking is:

Conceptualizing , not programming. Computer science is not only computer programming. Thinking like a computer scientist means more than being able to program a computer. It requires thinking at multiple levels of abstraction;

Fundamental , not rote skill. A fundamental skill is something every human being must know to function in modern society. Rote means a mechanical routine;

A way that humans, not computers, think . Computational thinking is a way humans solve problems; it is not trying to get humans to think like computers. Computers are dull and boring; humans are clever and imaginative. We humans make computers exciting. Equipped with computing devices, we use our cleverness to tackle problems we would not dare take on before the age of computing and build systems with functionality limited only by our imaginations;

Complements and combines mathematical and engineering thinking . Computer science inherently draws on mathematical thinking, given that, like all sciences, its formal foundations rest on mathematics. Computer science inherently draws on engineering thinking, given that we build systems that interact with the real world;

Ideas , not artifacts. It’s not just the software and hardware artifacts we produce that will be physically present everywhere and touch our lives all the time, it will be the computational concepts we use to approach and solve problems, manage our daily lives, and communicate and interact with other people;

For everyone, everywhere . Computational thinking will be a reality when it is so integral to human endeavors it disappears as an explicit philosophy. [2]

steps of problem solving in programming

Figure 2 “Are you happy?” by Typcut http://www.typcut.com/headup/are-you-happy

An algorithm specifies a series of steps that perform a particular computation or task. Throughout this book we’ll examine a number of different algorithms to solve a variety of computational problems.

Algorithms resemble recipes. Recipes tell you how to accomplish a task by performing a number of steps. For example, to bake a cake the steps are: preheat the oven; mix flour, sugar, and eggs thoroughly; pour into a baking pan; set the timer and bake until done.

However, “algorithm” is a technical term with a more specific meaning than “recipe”, and calling something an algorithm means that the following properties are all true:

  • An algorithm is an unambiguous description that makes clear what has to be implemented in order to solve the problem. In a recipe, a step such as “Bake until done” is ambiguous because it doesn’t explain what “done” means. A more explicit description such as “Bake until the cheese begins to bubble” is better. In a computational algorithm, a step such as “Choose a large number” is vague: what is large? 1 million, 1 billion, or 100? Does the number have to be different each time, or can the same number be used again?
  • An algorithm expects a defined set of inputs. For example, it might require two numbers where both numbers are greater than zero. Or it might require a word, or a list customer names.
  • An algorithm produces a defined set of outputs. It might output the larger of the two numbers, an all-uppercase version of a word, or a sorted version of the list of names.
  • An algorithm is guaranteed to terminate and produce a result, always stopping after a finite time. If an algorithm could potentially run forever, it wouldn’t be very useful because you might never get an answer.
  • Must be general for any input it is given. Algorithms solve general problems (determine if a password is valid); they are of little use if they only solve a specific problem (determine if ‘comp15’ is a valid password)
  • It is at the right level of detail…..the person or device executing the instruction know how to accomplish the instruction without any extra information.

Once we know it’s possible to solve a problem with an algorithm, a natural question is whether the algorithm is the best possible one. Can the problem be solved more quickly or efficiently?

The first thing you need to do before designing an algorithm is to understand completely the problem given. Read the problem’s description carefully, then read it again. Try sketching out by hand some examples of how the problem can be solved. Finally consider any special cases and design your algorithm to address them.

An algorithm does not solve a problem rather it gives you a series of steps that, if executed correctly, will result in a solution to a problem.

An Example Algorithm

Let us look at a very simple algorithm called find_max.

Problem : Given a list of positive numbers, return the largest number on the list.

Inputs : A list of positive numbers. This list must contain at least one number. (Asking for the largest number in a list of no numbers is not a meaningful question.)

Outputs : A number, which will be the largest number in the list.

Algorithm :

  • Accept a list of positive numbers; set to nums_list
  • Set max_number to 0.
  • If the number is larger, set max_number to the larger number.
  • max_number is now set to the largest number in the list of positive numbers, nums_list.

Does this meet the criteria for being an algorithm?

  • Is it unambiguous? Yes. Each step of the algorithm consists of uncomplicated operations, and translating each step into programming code is straight forward.
  • Does it have defined inputs and outputs? Yes.
  • Is it guaranteed to terminate? Yes. The list nums_list is of finite length, so after looking at every element of the list the algorithm will stop.
  • Is it general for any input? Yes. A list of any set of positive numbers works.
  • Does it produce the correct result? Yes. When tested, the results are what are expected

Figure 3: Example Algorithm

Figure 3: Example Algorithm

How do we know if an algorithm is unambiguous, correct, comes to an end, is general AND is at the right level of detail? We must test the algorithm. Testing means verifying that the algorithm does what we expect it to do. In our ‘bake a cake’ example we know our algorithm is ‘working’ if, in the end, we get something that looks, smells and tastes like a cake.

Verifying your Algorithm

steps of problem solving in programming

Figure 3 “ Keyboard ” by Geralt is licensed under CC 2

Your first step should be to carefully read through EACH step of the algorithm to check for ambiguity and if there is any information missing. To ensure that the algorithm is correct, terminates and is general for any input we devise ‘test cases’ for the algorithm.

A test case is a set of inputs, conditions, and expected results developed for a particular computational problem to be solved. A test case is really just a question that you ask of the algorithm (e.g. if my list is the three numbers 2, 14, and 11 does the algorithm return the number 14?). The point of executing the test is to make sure the algorithm is correct, that it terminates and is general for any input.

Good (effective) test cases:

  • are easy to understand and execute
  • are created with the user in mind (what input mistakes will be made? what are the preconditions?)
  • make no assumptions (you already know what it is supposed to do)
  • consider the boundaries for a specified range of values.

Let us look at the example algorithm from the previous section. The input for the algorithm is ‘a list of positive numbers’. To make it easy to understand and execute keep the test lists short. The preconditions are that the list only contains numbers and these numbers must be positive so include a test with a ‘non-number’ (i.e. a special character or a letter) and a test with a negative number. The boundaries for the list are zero and the highest positive number so include a test with zero and a large positive number. That is it! Here is an example of three different test cases.

Manually, you should step through your algorithm using each of the three test cases, making sure that the algorithm does indeed terminate and that you get your expected result. As our algorithms and programs become more complex, skilled programmers often break each test case into individual steps of the algorithm/program and indicate what the expected result of each step should be. When you write a detailed test case, you don’t necessarily need to specify the expected result for each test step if the result is obvious.

In computer programming we accept a problem to solve and develop an algorithm that can serve as a general solution. Once we have such a solution, we can use our computer to automate the execution. Programming is a skill that allows a competent programmer to take an algorithm and represent it in a notation (a program) that can be followed by a computer. These programs are written in programming languages (such as Python). Writing a correct and valid algorithm to solve a computational problem is key to writing good code. Learn to Think First and coding will come naturally!

The Process of Computational Problem Solving

Computational problem solving does not simply involve the act of computer programming. It is a process, with programming being only one of the steps. Before a program is written, a design for the program must be developed (the algorithm). And before a design can be developed, the problem to be solved must be well understood. Once written, the program must be thoroughly tested. These steps are outlined in Figure 5.

image

Figure 5: Process of Computational Problem Solving [footnote]Dierbach, Charles. Introduction to Computer Science Using Python: A Computational Problem-solving Focus. Wiley Publishing, 2012, pp17-18.[/footnote]

Values and Variables

A value is one of the basic things computer programs works with, like a password or a number of errors.

Values belong to different types: 21 is an integer (like the number of errors), and ‘comp15’ is a string of characters (like the password). Python lets you give names to values giving us the ability to generalize our algorithms.

One of the most powerful features of a programming language is the ability to use variables. A variable is simply a name that refers to a value as shown below,

Whenever the variable errors appears in a calculation the current value of the variable is used.

We need some way of storing information (i.e. the number of errors or the password) and manipulate them as well. This is where variables come into the picture. Variables are exactly what the name implies – their value can vary, i.e., you can store anything using a variable. Variables are just parts of your computer’s memory where you store some information. Unlike literal constants, you need some method of accessing these variables and hence you give them names.

Programmers generally choose names for their variables that are meaningful and document what the variable is used for. It is a good idea to begin variable names with a lowercase letter . The underscore character (_) can appear in a name and is often used in names with multiple words.

A program is a sequence of instructions that specifies how to perform a computation. The computation might be something mathematical, such as solving a system of mathematical equations or finding the roots of a polynomial, but it can also be a symbolic computation, such as searching and replacing text in a document or something graphical, like processing user input on an ATM device.

What is a Program?

image

Figure 6: “ Python Code ” by nyuhuhuu is licensed under CC-BY 2.0

The details look different in different computer programming languages, but there are some low-level conceptual patterns (constructs) that we use to write all programs. These constructs are not just for Python programs, they are a part of every programming language.

input Get data from the “outside world”. This might be reading data from a file, or even some kind of sensor like a microphone or GPS. In our initial algorithms and programs, our input will come from the user typing data on the keyboard.

output Display the results of the program on a screen or store them in a file or perhaps write them to a device like a speaker to play music or speak text.

sequential execution Perform statements one after another in the order they are encountered in the script.

conditional execution Checks for certain conditions and then executes or skips a sequence of statements.

repeated execution Perform some set of statements repeatedly, usually with some variation.

reuse Write a set of instructions once and give them a name and then reuse those instructions as needed throughout your program.

Believe it or not, that’s pretty much all there is to it. Every computer application you’ve ever used, no matter how complicated, is made up of constructs that look pretty much like these. So you can think of programming as the process of breaking a large, complex task into smaller and smaller subtasks until the subtasks are simple enough to be performed with one of these basic constructs. The “art” of writing a program is composing and weaving these basic elements together many times over to produce something that is useful to its users.

Computational Problem Design Using the Basic Programming Constructs

The key to better algorithm design and thus to programming lies in limiting the control structure to only three constructs as shown below.

  • The Sequence structure (sequential execution)
  • The Decision, Selection or Control structure (conditional execution)
  • Repetition or Iteration Structure (repeated execution)

image

Figure 7: the 3 Programming Constructs

  Let us look at some examples for the sequential control and the selection control.

Sequential Control Example

The following algorithm is an example of sequential control .

Problem : Given two numbers, return the sum and the product of the two numbers.

Inputs : Two numbers.

Outputs : The sum and the product.

  • display “Input two numbers”
  • sum = number1 + number2
  • print “The sum is “, sum
  • product = number1 * number2
  • print “The product is “, product
  • Is it guaranteed to terminate? Yes. Sequential control, by its nature, always ends.
  • Is it general for any input? Yes. Any two numbers work in this design.
  • Does it produce the correct result? Yes. When tested, the results are what are expected.

Here is an example of three different test cases that are used to verify the algorithm.

Selection Control

The following two algorithms are examples of selection control which uses the ‘IF’ statement in most programming languages.

Problem : Given two numbers, the user chooses to either multiply, add or subtract the two numbers. Return the value of the chosen calculation.

Inputs : Two numbers and calculation option.

Outputs : The value of the chosen calculation.

The relational (or comparison) operators used in selection control are:

= is equal to

> is greater than

< is less than

>= is greater than or equal

<= is less than or equal

<> is not equal to

  • display “choose one of the following”
  • display “m for multiply”
  • display “a for add”
  • display “s for subtract”
  • accept choice
  • display “input two numbers you want to use”
  • accept number1, number2
  • if choice = m then answer= number1 * number2
  • if choice = a then answer= number1 + number2
  • if choice = s then answer= number1 -number212. if choice is not m, a, or s then answer is NONE
  • display answer
  • Is it guaranteed to terminate? Yes. The input is of finite length, so after accepting the user’s choice and the two numbers the algorithm will stop.
  • Is it general for any input? Yes. Any two numbers work in this design and only a choice of a’m’, ‘a’, or ‘s’ will result in numeric output.

This example uses an extension of the simple selection control structure we just saw and is referred to as the ‘IF-ELSE’ structure.

Problem : Accept from the user a positive integer value representing a salary amount, return tax due based on the salary amount.

Inputs : One positive integer number.

Outputs : The calculated tax amount.

  • accept salary
  • If salary < 50000 then
  • Tax = 0 Else
  • If salary > 50000 AND salary < 100000 then
  • Tax = 50000 * 0.05 Else
  • Tax = 100000 * 0.30
  • display Tax
  • Is it guaranteed to terminate? Yes. The input is of finite length, so after accepting the user’s number, even if it is negative, the algorithm will stop.
  • Is it general for any input? Yes. Any number entered in this design will work.

Iterative Control Examples

The third programming control is the iterative or, also referred to as, the repetition structure. This control structure causes certain steps to be repeated in a sequence a specified number of times or until a condition is met. This is what is called a ‘loop’ in programming

In all programming languages there are generally two options: an indefinite loop (the Python ‘WHILE’ programming statement) and a definite loop (the Python ‘FOR’ programming statement). We can use these two constructs, WHILE and FOR, for iterations or loops in our algorithms.

Note for Reader: A definite loop is where we know exactly the number of times the loop’s body will be executed. Definite iteration is usually best coded as a Python for loop. An indefinite loop is where we do not know before entering the body of the loop the exact number of iterations the loop will perform. The loop just keeps going until some condition is met. A while statement is used in this case.

The following algorithm is an example of iterative control using WHILE .

Problem : Print each keyboard character the users types in until the user chooses the ‘q’ (for ‘quit’) character.

Inputs : A series of individual characters.

Outputs : Each character typed in by the user.

  • initialize (set) letter = ‘a’
  • WHILE letter <> ‘q’
  • ACCEPT letter
  • DISPLAY “The character you typed is”, letter
  • Is it guaranteed to terminate? Yes. The input is of finite length, so after accepting the user’s keyboard character, even if it is not a letter, the algorithm will stop.
  • Is it general for any input? Yes. Any keyboard character entered in this design will work.

The following algorithm is an example of iterative control using FOR . This statement is used when the number of iterations is known in advance.

Problem : Ask the user how many words they want to enter then print the words entered by the user.

Inputs : Number of words to be entered; this value must be a positive integer greater than zero. Individual words.

Outputs : Each word typed in by the user.

  • accept num_words (must be at least one)
  • repeat num_words times (FOR 1 to num_words)
  • accept word
  • DISPLAY “The word you entered is”, word
  • Is it guaranteed to terminate? Yes. The input is of finite length, so after accepting the user’s number of words to enter and any characters typed on the keyboard, even if it is not a ‘word’ per say, the algorithm will stop.
  • Is it general for any input? Yes. Any positive integer greater than zero and any size ‘word’ will work.

Here is an example of two different test cases that are used to verify the algorithm.

The Role of Programming in the Field of Informatics

image

Figure8: iPhone apps by Jaap Arriens/NurPhoto via Getty Images (abcnews.go.com)

You see computer programming in use every day. When you use Google or your smartphone, or watch a movie with special effects, there is programing at work. When you order a product over the Internet, there is code in the web site, in the cryptography used to keep your credit card number secure, and in the way that UPS routes their delivery vehicle to get your order to you as quickly as possible.

Programming is indeed important to an informatics professional as they are interested in finding solutions for a wide variety of computational problems involving data.

When you Google the words “pie recipe,” Google reports that it finds approximately 38 million pages, ranked in order of estimated relevance and usefulness. Facebook has approximately 1 billion active users who generate over 3 billion comments and “Likes” each day. GenBank, a national database of DNA sequences used by biologists and medical researchers studying genetic diseases, has over 100 million genetic sequences with over 100 billion DNA base pairs. According to the International Data Corporation, by 2020 the digital universe – the data we create and copy annually – will reach 44 zettabytes, or 44 trillion gigabytes.

image

Figure 9: The Digital Universe ( www.emc.com/leadership/digital-universe/2014iview/images )

  Doing meaningful things with data is challenging, even if we’re not dealing with millions or billions of things. In this book, we will be working with smaller sets of data. But much of what we’ll do will be applicable to very large amounts of data too.

Unit Summary

Computational Thinking is the thought processes involved in formulating a problem and expressing its solution in a way that a computer—human or machine—can effectively carry out.

Computational Thinking is what comes before any computing technology—thought of by a human, knowing full well the power of automation.

Writing a correct and valid algorithm to solve a computational problem is key to writing good code.

  • What are the inputs?
  • What are the outputs (or results)?
  • Can we break the problem into parts?
  • Think about the connections between the input & output.
  • Consider designing ‘backwards’.
  • Have you seen the problem before? In a slightly different form?
  • Can you solve part of the problem?
  • Did you use all the inputs?
  • Can you test it on a variety of inputs?
  • Can you think of how you might write the algorithm differently if you had to start again?
  • Does it solve the problem? Does it meet all the requirements? Is the output correct?
  • Does it terminate?
  • Is it general for all cases?

Practice Problems

  • Write about a process in your life (e.g. driving to the mall, walking to class, etc.) and estimate the number of steps necessary to complete the task. Would you consider this a complex or simple task? What happens if you scale that task (e.g. driving two states away to the mall)? Is your method the most efficient? Can you come up with a more efficient way?

image

  • Write an algorithm to find the average of 25 test grades out of a possible 100 points.
  • If you are given three sticks, you may or may not be able to arrange them in a triangle. For example, if one of the sticks is 12 inches long and the other two are one inch long, it is clear that you will not be able to get the short sticks to meet in the middle. For any three lengths, there is a simple test to see if it is possible to form a triangle: “If any of the three lengths is greater than the sum of the other two, then you cannot form a triangle. Otherwise, you can.”Write an algorithm that accepts three integers as arguments, and that displays either “Yes” or “No,” depending on whether you can or cannot form a triangle from sticks with the given lengths.
  • ROT13 is a weak form of encryption that involves “rotating” each letter in a word by 13 places. To rotate a letter means to shift it through the alphabet, wrapping around to the beginning if necessary, so ‘A’ shifted by 3 is ‘D’ and ‘Z’ shifted by 1 is ‘A’. Write an algorithm that accepts a word and an integer from the user, and that prints a new encrypted word that contains the letters from the original word “rotated” by the given amount (the integer input). For example, “cheer” rotated by 7 is “jolly” and “melon” rotated by −10 is “cubed.”
  • Write an algorithm which repeatedly accepts numbers until the user enters “done”. Once “done” is entered, display the total sum of all the numbers, the count of numbers entered, and the average of all the numbers.
  • Write an algorithm that sums a series of ten positive integers entered by the user excluding all numbers greater than 100. Display the final sum.
  • Wing, Jeannette M. "Computational thinking." Communications of the ACM 49.3 (2006): 33-35. ↵

Footer Logo Lumen Candela

Privacy Policy

steps of problem solving in programming

  • Latest Articles
  • Top Articles
  • Posting/Update Guidelines
  • Article Help Forum

steps of problem solving in programming

  • View Unanswered Questions
  • View All Questions
  • View C# questions
  • View C++ questions
  • View Javascript questions
  • View Visual Basic questions
  • View Python questions
  • CodeProject.AI Server
  • All Message Boards...
  • Running a Business
  • Sales / Marketing
  • Collaboration / Beta Testing
  • Work Issues
  • Design and Architecture
  • Artificial Intelligence
  • Internet of Things
  • ATL / WTL / STL
  • Managed C++/CLI
  • Objective-C and Swift
  • System Admin
  • Hosting and Servers
  • Linux Programming
  • .NET (Core and Framework)
  • Visual Basic
  • Web Development
  • Site Bugs / Suggestions
  • Spam and Abuse Watch
  • Competitions
  • The Insider Newsletter
  • The Daily Build Newsletter
  • Newsletter archive
  • CodeProject Stuff
  • Most Valuable Professionals
  • The Lounge  
  • The CodeProject Blog
  • Where I Am: Member Photos
  • The Insider News
  • The Weird & The Wonderful
  • What is 'CodeProject'?
  • General FAQ
  • Ask a Question
  • Bugs and Suggestions

steps of problem solving in programming

The Beginner Programmer's guide to Problem Solving [With Example]

steps of problem solving in programming

Have you got this feeling that you are able to grasp the concepts of programming and  you are able to understand what’s a variable, what’s a function, what are data types, etc. yet you find it difficult to solve problems in programming.  Every beginner gets this feeling.  I did too when starting out.

It is important to overcome this feeling at the earliest, otherwise it can form a mental block for you.

Image 1

How it can be a mental block to you?  Common sense says that the more you practice a certain skill, you get better at that skill as time progresses.  Same goes with problem solving too.  The more problems you solve, the better you become at problem solving.  But when you get a feel that you are trying hard and still unable to solve a problem or find it extremely difficult, your confidence lowers.  At this stage, either you stop solving problems or try to solve lesser number of problems.

The point is your curriculum or your professional work is generally designed in such a manner that the order of difficulty increases as time progresses.  So, you are in a situation where you feel less confident in solving small problems but now tasked with solving bigger problems.  And the cycle continues till it becomes a permanent mental block in you.

Is it too late to start solving problems?

No.  If you have come to the realization that you need to improve your problem solving skills, you have made that good first step.  Quite often our egos don’t let us accept the obvious.  It is good to accept certain truth because that is the only way that we can improve ourselves.

What can I do to become better at solving problems?

Remove the mental block first – exercise your mind.

Your mind is your most powerful weapon.  So you have to think you can actually solve the problem.  So from today, think positively that you can solve any problem.  But you will obviously start with small problems and go on to solve bigger problems.

As with every aspect in life, it starts with conditioning the mind.  So, starting today, tell yourselves the following:

  • I can solve any problem that is put at me
  • I will commit at least 1-2 hours per day on solving problems alone for the next 30 days
  • I will never give up on any problem that is put at me, I will ask for help if required.1

Understand the basic approach to problem solving

Do you know one of the reasons for your struggle with problem solving?  One reason might be due to lack of practice.  But the main reason is because you have not understood the basics of problem solving especially in programming.  Once you understand the approach to problem solving to the smallest of things, you can go ahead and solve bigger and more complex problems with confidence.1

Ever wondered how top tech companies like Google, Amazon solved the internet’s biggest & hardest problems?  The answer is simplicity.  They solved problems at the basic level and then went on to solve bigger and bigger problems.  You can do it too.  But you need to be good at the basics.

What do I need to understand before even trying to solve the problem?

Understand the problem clearly – the power of clarity.

You need to understand your problem clearly before even trying to solve it1.  Lack of clarity at this stage will put you down.  So make a conscious effort in understanding the problem more clearly.  Ask questions like What, Why, When, Where, What if and How.  Not all questions might be applicable to your problem, but it is important to ask questions to yourself at this stage before you go ahead trying to solve the problem.

Visualize – The Power of visualization

I am sure everyone of you is aware of what visualization is.  Trying to picturize your thoughts.  Have you ever imagined how some people can solve extra ordinary problems just by looking into those problems and they will instantly have a solution to it?  And we don’t even understand the problem fully?  It is because they do it with their mind.  They visualize the problem in their minds and they solve it in their minds itself.  Visualization is a powerful tool in your mind.

But in order to get to that state, first you need to visualize the problem externally.  That is where a pen and a paper/notebook (or) a white board comes into play1.  Try to visualize the problem at hand and try to picturize the problem.  That is also one of the steps to make sure that you understand the problem clearly.

There was a situation when I and my dear friend & colleague were discussing about a problem and we were literally going nowhere.  This was actually when we each had around 7 years of experience in the industry.  At that point, my friend said “Let’s put our points in board.  If we don’t put it on the board, we will never get started”.  And we started putting things on board.  Things started to get more clear and raised more questions and ultimately became more clear.

That is the power of visualization.  It really helps us to get started with our thinking. This visual thing works.  Just try it out.

Your next question might be “I kinda get it, but I don’t.  How do I visualize? What exactly do I visualize?”.  Please read on to find out the answers.

What is the basic approach to problem solving

Step 1:  identify small problems.

The major trick in problem solving is to identify and solve the smallest problem and then moving ahead with bigger ones.  So how do you do it?

The answer is division of responsibility.  Simply put, we need to identify parts that can stand on its own and identify a sequence in those responsibilities.  And once you start breaking down the problems into smaller ones, then you can go ahead with the next step.

Step 2:  Solve the smaller problems one at a time

Now that you have identified the smaller problems, try to solve them.  While solving them, make sure that you are focussing only on one problem at a time.  That makes life much simpler for us.  If you feel that this smaller problem is too big to solve on its own, try to break it down further.  You need to iterate steps 1 to step 3 for each smaller problem.  But for now, ignore the bigger problem and solve the rest of the problems.

  • It is ok to assume that other problems are solved
  • It is ok to hardcode when coding a particular problem, but later you will resolve it in step 3.
  • Solve the easier problems first, that will give you confidence and momentum until you get the confidence to solve the hardest problem first.

Step 3: Connect the dots (Integration)

You have solved individual problems.  Now it is time to connect the dots by connecting the individual solution.  Identify those steps which will make the solution or the program complete.  Typically in programming, the dots are connected by passing data that is stored in variables.

Step 4: Try to optimize each step & across steps

Once you are completed with a working solution, try to optimize the solution with the best code that you can write.  This comes only with practice.  This trick can make a difference between a good programmer and a great programmer.  But to get to this step, you need to be first good at steps 1 to 3.

Let’s take an example & walkthrough the problem solving approach

Problem:  check if a user given string is a palindrome or not.

I will be using Python for this exercise (Although I have experience in1 C# and JAVA, I am also a Python beginner, so pardon any bad code).  Let’s iterate through our steps:

Let’s call this as Level 1:

Step 1:  Identify smaller problems:

Image 2

Step 2: Solve the small problems

So each small problem will map to its corresponding solution as below:

Image 3

Note: When solving the step (3.  Compare the variables), I am doing 2 things:

  • I am making an assumption that reversed is the variable name of the reversed string.
  • I am hardcoding the variable name reversed to ‘madam’ to avoid compile time error
  • If you execute the program at this state, you can input ‘madam’ and check if it is printing ‘The given string is a palindrome’ (And) you can input something else like ‘dog’ and check if it is printing ‘The given string is not a palindrome’

When we are trying to connect the dots, the only thing that is missing now is the variable reversed is hardcoded.  For that to be set to the correct value, we need to break the small problem (Reverse the user input and store in a separate variable) into further smaller problems.  Till that point we need to mark it as incomplete.

2 things still remain unsolved in Level 1:

  • Solution for step 2 in the diagram (Reverse the user input and store in a separate variable)
  • Connecting the dots once the solution for step 2 is found

Iterating small problem 2 through our problem solving steps:

Let’s call this Level 2:

Step 1: Identify smaller problems

Image 4

Step 3: Connect the dots

Here, we have already connected the dots.  So we need not do anything extra in this step.

Now we have solved the smaller problems, which means Level 2 is over.  Now we need to come back to Level 1.

If you remember, 2 things remain in Level 1.  One is solution for step 2 which we have found now.  Two is connecting the dots.

Now if we substitute the small problem 2 with the solution that we derived just now, we get something like this:

Image 6

The thing that remains is connecting the dots.

So if we see what is the missing connection, the variable reversed is set twice.  One to the solution of step 2 and another is hardcoded in step 3.  So we can now remove the hardcoded value in step 3, in which case our code will become like this

Image 7

If you see, we have actually solved our problem.

We are left with step 4 – Optimize each step and across steps

Step 4: Try to optimize each step and across steps

As you can see, there are many things that needs to be optimized for this code.  I would leave you to optimize the code further.  Come on, put on your thinking cap and try different solutions.

BONUS STEP 5:  Make the code robust

By robust I mean,

  • Adding error & exception handling
  • Using better variable names
  • Adding user defined functions
  • Adding comments where necessary

Again, I would leave you to figure out how to do this step.

  • We saw just how we can solve problems using a step by step approach
  • By solving smaller problems, I get into a momentum for solving bigger & tougher problems
  • By focussing one problem at a time, I am eliminating distractions, thus allowing to better direct your efforts for that one problem rather than getting confused with many small problems at hand.
  • If you understand this approach and practice, you will definitely go on to solve bigger problems and your confidence will raise.
  • Beauty about breaking down the problem is that we can further convert each problem and sub problem into separate functions/modules thus making the code more modularized and maintainable.

Wait, You can’t leave yet:

Now dear beginner programmers, take any problem and try to apply this approach.  See the results for yourselves.  Now, describe the following in the comments section:

  • What problem you are solving?
  • How did you break it down? (Even a snap of your notebook page or board will do!)
  • The final code
  • How did you feel and what did you learn from this exercise?

Also remember, I am challenging you for the 30 day problem solving challenge.

If you liked this blog post, please feel free to share it with your circles in social media.

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Twitter

Comments and Discussions

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

steps of problem solving in programming

Python Wife Logo

  • Computer Vision
  • Problem Solving in Python
  • Intro to DS and Algo
  • Analysis of Algorithm
  • Dictionaries
  • Linked Lists
  • Doubly Linked Lists
  • Circular Singly Linked List
  • Circular Doubly Linked List
  • Tree/Binary Tree
  • Binary Search Tree
  • Binary Heap
  • Sorting Algorithms
  • Searching Algorithms
  • Single-Source Shortest Path
  • Topological Sort
  • Dijkstra’s
  • Bellman-Ford’s
  • All Pair Shortest Path
  • Minimum Spanning Tree
  • Kruskal & Prim’s

Problem-solving is the process of identifying a problem, creating an algorithm to solve the given problem, and finally implementing the algorithm to develop a computer program .

An algorithm is a process or set of rules to be followed while performing calculations or other problem-solving operations. It is simply a set of steps to accomplish a certain task.

In this article, we will discuss 5 major steps for efficient problem-solving. These steps are:

  • Understanding the Problem
  • Exploring Examples
  • Breaking the Problem Down
  • Solving or Simplification
  • Looking back and Refactoring

While understanding the problem, we first need to closely examine the language of the question and then proceed further. The following questions can be helpful while understanding the given problem at hand.

  • Can the problem be restated in our own words?
  • What are the inputs that are needed for the problem?
  • What are the outputs that come from the problem?
  • Can the outputs be determined from the inputs? In other words, do we have enough information to solve the given problem?
  • What should the important pieces of data be labeled?

Example : Write a function that takes two numbers and returns their sum.

  • Implement addition
  • Integer, Float, etc.

Once we have understood the given problem, we can look up various examples related to it. The examples should cover all situations that can be encountered while the implementation.

  • Start with simple examples.
  • Progress to more complex examples.
  • Explore examples with empty inputs.
  • Explore examples with invalid inputs.

Example : Write a function that takes a string as input and returns the count of each character

After exploring examples related to the problem, we need to break down the given problem. Before implementation, we write out the steps that need to be taken to solve the question.

Once we have laid out the steps to solve the problem, we try to find the solution to the question. If the solution cannot be found, try to simplify the problem instead.

The steps to simplify a problem are as follows:

  • Find the core difficulty
  • Temporarily ignore the difficulty
  • Write a simplified solution
  • Then incorporate that difficulty

Since we have completed the implementation of the problem, we now look back at the code and refactor it if required. It is an important step to refactor the code so as to improve efficiency.

The following questions can be helpful while looking back at the code and refactoring:

  • Can we check the result?
  • Can we derive the result differently?
  • Can we understand it at a glance?
  • Can we use the result or mehtod for some other problem?
  • Can you improve the performance of the solution?
  • How do other people solve the problem?

Trending Posts You Might Like

  • File Upload / Download with Streamlit
  • Seaborn with STREAMLIT
  • Dijkstra’s Algorithm in Python
  • Greedy Algorithms in Python

Author : Bhavya

  • Become a Member
  • Artificial Intelligence
  • Computational Thinking
  • Digital Citizenship
  • Edtech Selection
  • Global Collaborations
  • STEAM in Education
  • Teacher Preparation
  • ISTE Certification
  • School Partners
  • Career Development
  • ISTELive 24
  • 2024 ASCD Annual Conference
  • Solutions Summit
  • Leadership Exchange
  • 2024 ASCD Leadership Summit
  • Edtech Product Database
  • Solutions Network
  • Sponsorship & Advertising
  • Sponsorship & Advertising
  • Learning Library

Computer Programming in 4 Steps

  • Computer Science & Computational Thinking

CT in 4 Steps blog Version Idssc Y Ai8d Fwp GNFK7i It3i A Aynv Ir 1 Z1

If your school is still teaching core  computer science (CS) concepts and practices under the umbrella of career and technical education (CTE) or within the cluster of  information technology (IT) courses, you should consider branching out.

Computer science (CS) has infiltrated nearly everything humans do — from our jobs and hobbies to the way we organize our homes and plan our vacations. Therefore, CS should be embedded in every subject, from science and literature and electives like art and design . 

No matter the discipline, creating computational artifacts is one of the core CS practices students should consistently experience to become better problem-solvers. Computational artifacts may include images, videos, presentations, audio files and computer programs.

Precise and consistent practice in computer programming (CP) will help students construct cross-curricular knowledge in tandem with both academic and CS concepts and practices. As CP is the process of writing a program from start to finish, students receive exposure in the amalgamation of practices 3-6 found in the K-12 Computer Science Framework.

So, how can we successfully engage students in CP? Here’s how we can do so in four major steps.

Step 1: Identify the problem

When students are new to CP, we typically start teaching them how to program and code using tutorials . Although there’s nothing wrong with that, we don’t want to keep them there.

Usually the writer of a tutorial has already identified both the problem and the solution of the program. The best way for kids to learn is by writing their own problems and solutions and creating their own programs. Otherwise, they will focus more on learning to code specific functions in a particular language, which is generally no different than rote memorization , which should be replaced with the development of working memory .

Identifying (or defining) the problem is the most critical part of the CP process as students will need to develop a concrete plan for what their complete program will do. This process involves identifying both the known inputs (or given data) and what is to be obtained via outputs (the result). Although CP isn’t a simple process, consistent and precise practice will build student confidence over time in articulating the details on the kind of input, processing and output desired for their programs. To get students started in programming, read this great intro to a lesson for building and sharing apps by Code.org.

Step 2: Find a solution

To find or plan the solution to the problem identified in Step 1, students can either create a flowchart or write pseudocode . Experienced programmers can and will use either of these methods to convey program development to clients, teachers, etc.

A flowchart is a step-by-step solution to a problem that uses a pictorial representation of the direction of the program and consists of arrows, boxes and other symbols that represent actions (i.e., input/output, process, etc.). Pseudocode is similar to English and is used to convey the solution with more accuracy than in plain English — but with less meticulousness required by a formal programming language.

The solution process enables the programmer to focus on the logical flow of the program without having to adhere to the actual syntax used by the programming language for the project. Check out this fun Technovation lesson  to help your students plan their code.

Step 3: Code it

Often coding is confused with programming, but coding is just one part of the programming process. Good coders can create instructions from the solutions (discussed in Step 2) and write them into code for the computer to understand. This is where the algorithmic design skills from computational thinking come into play.

It helps when you think of your problem as a math problem, not because you’re always doing a lot of math while programming, but because the thought process is the same. In mathematics we often use algorithmic sets of instructions that we follow in a sequence of steps to achieve a goal. That process is likened to both a well-detailed flowchart and code (in a specific programming language). 

Practicing coding will help students understand that coding isn’t complicated when they learn how to think logically and in steps. Getting students started by writing simple programs will teach them how to give computers instructions, how computers actually work and that good coders aren’t vague and don’t skip steps. They will also understand that the code they write is processed (translated) by a compiler into machine language for execution .

For kids new to coding, I recommend starting with a visual programming language (VPL), which allows kids to describe their algorithms using illustrations and lets coders describe the process in terms that make sense to them.

Here are some popular VPLs:

  • Scratch , ScratchJr
  • Ardublock (block programming language for Arduino)
  • ROBOLAB (programming language for LEGO Robotics)
  • ROBOTC (graphical for VEX Robotics)
  • LabVIEW (National Instruments)

Although there are several ways to get students started in coding, I highly recommend your entire school participate in an Hour of Code and also teach kids to code within the context of a STEM/ STEAM design challenge .

Step 4: Test it

Testing  in CP is a critical process used to determine the quality of a program and find bugs (problems). As a college intern, I was first introduced to testing and debugging of ActiveX Controls in the Visual Basic programming language. Although testing has different levels and will determine if programs work or don’t — working to find bugs for the software developers to correct was very powerful in helping me understand the quality of the programs I used every day and also the importance of updating them regularly. 

Requiring students to present their work publicly , is an excellent technique for engaging and instilling in them the importance of the testing process for discussing and showcasing high-quality CS work. Again, the App Lab (in Step 1) is a great lesson and project for helping kids learn CP from start to testing.

CP for different grade levels

Computer programming can be taught at all grade levels. Here are some tools to use with various ages and levels of learners. 

Grades 3-8: littleBits Code Kit

The  code kit  comes equipped with electronic building blocks and an app with coding tutorials, and is an excellent scaffold for teaching students the concepts of coding, light, sound and motion in the context of a design challenge or invention.

What I find most powerful about the code kit is the app because it helps users become grounded in basic coding principles. A good coder, no matter the language or coding experience, will need to understand the basics — like input/output, loops, functions, variables and also logic. Success always relates to developing internal self-mastery of the fundamentals. Like Dr. Stephen R. Covey, author of The 7 Habits of Highly Effective People , once said, “Put first things first.”

The code kit also works in conjunction with all of the educational resources an educator would need, including lesson plans, student handouts and alignment to the Next Generation Science Standards. Many of the resources were tested and developed by the littleBits Lead Educator Cohort of 2017 and as a proud member, I was very fortunate to have worked and learned with such a talented group of educators!  

Grades 6-8: robotics  

Getting kids started in programming is fairly easy. In my previous role as a curriculum specialist, we used the Lego Mindstorms robot as the intro. These were the steps we took in helping kids understand key concepts, as well as programming:

  • Build their robots . Practically every kid loved this part.
  • Learn the basics. Through exploring tutorials, they learned about motors, sensors, gears and other components .
  • Learn to program . The brick had six built-in missions, which enabled students to see how to make the robot move with motors and respond to touch or motion with sensors. As they became more accustomed to the built-in programs, they started making their own programs, using ROBOLAB programming blocks.
  • Connect to CS and STEM . We found that this helped greatly elucidate the concepts and practice of both pattern recognition and algorithmic design. And then, of course, lessons in CS and STEM, which included coding, force and motion, and design and technology. We also found that the VEX IQ Kit was great for similar purposes and we used both VEX and Lego, based on the different competitive events that our students participated in.

Grades 8-12: advanced robotic s

For high school students who’ve already practiced coding using a VPL and either have or are mastering foundational programming principles, the next step is to get them coding in an industry sought-after programming language like JavaScript, Python, Pearl or C++. Luckily programming a robot like the VEX EDR gives high schoolers an intro to this valuable learning experience. Students programming the VEX EDR learn to use the ROBOTC C-based programming language and can see the effects of the code they write in real time by solving problems using the engineering design process .

I recently began learning to program the VEX EDR when I participated in an Engineering Design course training with the International Technology and Engineering Educator’s Association . It was there that I met and was partnered with Tim Oltman — the Martha Layne Collins high school teacher of the year. He and fellow teacher Shane Ware have considerable experience teaching kids to program robots for various VEX robotics competitive events and have won numerous awards in Kentucky.

I asked Tim for his thoughts on how teachers should proceed when moving kids from programming in a VPL to a C-based program like for VEX, and he said, “First, build relationships with your students, and then learn with them. Let them see you try and fail, and they will enjoy struggling through the process with you. Eventually, they will surpass you and become the teachers.”

Jorge Valenzuela is an education coach, author and advocate. He has years of experience as a classroom and online teacher, a curriculum specialist and as a consultant. His work focuses on improving teacher preparation in project-based learning, computational thinking and computer science integration, STEM education, and equity-based restorative practices. Jorge is an adjunct professor at Old Dominion University and the lead coach at  Lifelong Learning Defined . His book  Rev Up Robotics: Real-World Computational Thinking in the K–8 Classroom  is available from ISTE. This is an updated version of a post that originally published on March 20, 2018. 

  • artificial intelligence

Cart

  • SUGGESTED TOPICS
  • The Magazine
  • Newsletters
  • Managing Yourself
  • Managing Teams
  • Work-life Balance
  • The Big Idea
  • Data & Visuals
  • Reading Lists
  • Case Selections
  • HBR Learning
  • Topic Feeds
  • Account Settings
  • Email Preferences

Share Podcast

HBR On Strategy podcast series

A Better Framework for Solving Tough Problems

Start with trust and end with speed.

  • Apple Podcasts

When it comes to solving complicated problems, the default for many organizational leaders is to take their time to work through the issues at hand. Unfortunately, that often leads to patchwork solutions or problems not truly getting resolved.

But Anne Morriss offers a different framework. In this episode, she outlines a five-step process for solving any problem and explains why starting with trust and ending with speed is so important for effective change leadership. As she says, “Let’s get into dialogue with the people who are also impacted by the problem before we start running down the path of solving it.”

Morriss is an entrepreneur and leadership coach. She’s also the coauthor of the book, Move Fast and Fix Things: The Trusted Leader’s Guide to Solving Hard Problems .

Key episode topics include: strategy, decision making and problem solving, strategy execution, managing people, collaboration and teams, trustworthiness, organizational culture, change leadership, problem solving, leadership.

HBR On Strategy curates the best case studies and conversations with the world’s top business and management experts, to help you unlock new ways of doing business. New episodes every week.

  • Listen to the full HBR IdeaCast episode: How to Solve Tough Problems Better and Faster (2023)
  • Find more episodes of HBR IdeaCast
  • Discover 100 years of Harvard Business Review articles, case studies, podcasts, and more at HBR.org .

HANNAH BATES: Welcome to HBR On Strategy , case studies and conversations with the world’s top business and management experts, hand-selected to help you unlock new ways of doing business.

When it comes to solving complicated problems, many leaders only focus on the most apparent issues. Unfortunately that often leads to patchwork or partial solutions. But Anne Morriss offers a different framework that aims to truly tackle big problems by first leaning into trust and then focusing on speed.

Morriss is an entrepreneur and leadership coach. She’s also the co-author of the book, Move Fast and Fix Things: The Trusted Leader’s Guide to Solving Hard Problems . In this episode, she outlines a five-step process for solving any problem. Some, she says, can be solved in a week, while others take much longer. She also explains why starting with trust and ending with speed is so important for effective change leadership.

This episode originally aired on HBR IdeaCast in October 2023. Here it is.

CURT NICKISCH: Welcome to the HBR IdeaCast from Harvard Business Review. I’m Curt Nickisch.

Problems can be intimidating. Sure, some problems are fun to dig into. You roll up your sleeves, you just take care of them; but others, well, they’re complicated. Sometimes it’s hard to wrap your brain around a problem, much less fix it.

And that’s especially true for leaders in organizations where problems are often layered and complex. They sometimes demand technical, financial, or interpersonal knowledge to fix. And whether it’s avoidance on the leaders’ part or just the perception that a problem is systemic or even intractable, problems find a way to endure, to keep going, to keep being a problem that everyone tries to work around or just puts up with.

But today’s guest says that just compounds it and makes the problem harder to fix. Instead, she says, speed and momentum are key to overcoming a problem.

Anne Morriss is an entrepreneur, leadership coach and founder of the Leadership Consortium and with Harvard Business School Professor Francis Frei, she wrote the new book, Move Fast and Fix Things: The Trusted Leaders Guide to Solving Hard Problems . Anne, welcome back to the show.

ANNE MORRISS: Curt, thank you so much for having me.

CURT NICKISCH: So, to generate momentum at an organization, you say that you really need speed and trust. We’ll get into those essential ingredients some more, but why are those two essential?

ANNE MORRISS: Yeah. Well, the essential pattern that we observed was that the most effective change leaders out there were building trust and speed, and it didn’t seem to be a well-known observation. We all know the phrase, “Move fast and break things,” but the people who were really getting it right were moving fast and fixing things, and that was really our jumping off point. So when we dug into the pattern, what we observed was they were building trust first and then speed. This foundation of trust was what allowed them to fix more things and break fewer.

CURT NICKISCH: Trust sounds like a slow thing, right? If you talk about building trust, that is something that takes interactions, it takes communication, it takes experiences. Does that run counter to the speed idea?

ANNE MORRISS: Yeah. Well, this issue of trust is something we’ve been looking at for over a decade. One of the headlines in our research is it’s actually something we’re building and rebuilding and breaking all the time. And so instead of being this precious, almost farbege egg, it’s this thing that is constantly in motion and this thing that we can really impact when we’re deliberate about our choices and have some self-awareness around where it’s breaking down and how it’s breaking down.

CURT NICKISCH: You said break trust in there, which is intriguing, right? That you may have to break trust to build trust. Can you explain that a little?

ANNE MORRISS:  Yeah, well, I’ll clarify. It’s not that you have to break it in order to build it. It’s just that we all do it some of the time. Most of us are trusted most of the time. Most of your listeners I imagine are trusted most of the time, but all of us have a pattern where we break trust or where we don’t build as much as could be possible.

CURT NICKISCH: I want to talk about speed, this other essential ingredient that’s so intriguing, right? Because you think about solving hard problems as something that just takes a lot of time and thinking and coordination and planning and designing. Explain what you mean by it? And also, just  how we maybe approach problems wrong by taking them on too slowly?

ANNE MORRISS: Well, Curt, no one has ever said to us, “I wish I had taken longer and done less.” We hear the opposite all the time, by the way. So what we really set out to do was to create a playbook that anyone can use to take less time to do more of the things that are going to make your teams and organizations stronger.

And the way we set up the book is okay, it’s really a five step process. Speed is the last step. It’s the payoff for the hard work you’re going to do to figure out your problem, build or rebuild trust, expand the team in thoughtful and strategic ways, and then tell a real and compelling story about the change you’re leading.

Only then do you get to go fast, but that’s an essential part of the process, and we find that either people under emphasize it or speed has gotten a bad name in this world of moving fast and breaking things. And part of our mission for sure was to rehabilitate speed’s reputation because it is an essential part of the change leader’s equation. It can be the difference between good intentions and getting anything done at all.

CURT NICKISCH: You know, the fact that nobody ever tells you, “I wish we had done less and taken more time.” I think we all feel that, right? Sometimes we do something and then realize, “Oh, that wasn’t that hard and why did it take me so long to do it? And I wish I’d done this a long time ago.” Is it ever possible to solve a problem too quickly?

ANNE MORRISS: Absolutely. And we see that all the time too. What we push people to do in those scenarios is really take a look at the underlying issue because in most cases, the solution is not to take your foot off the accelerator per se and slow down. The solution is to get into the underlying problem. So if it’s burnout or a strategic disconnect between what you’re building and the marketplace you’re serving, what we find is the anxiety that people attach to speed or the frustration people attach to speed is often misplaced.

CURT NICKISCH: What is a good timeline to think about solving a problem then? Because if we by default take too long or else jump ahead and we don’t fix it right, what’s a good target time to have in your mind for how long solving a problem should take?

ANNE MORRISS: Yeah. Well, we’re playful in the book and talking about the idea that many problems can be solved in a week. We set the book up five chapters. They’re titled Monday, Tuesday, Wednesday, Thursday, Friday, and we’re definitely having fun with that. And yet, if you count the hours in a week, there are a lot of them. Many of our problems, if you were to spend a focused 40 hours of effort on a problem, you’re going to get pretty far.

But our main message is, listen, of course it’s going to depend on the nature of the problem, and you’re going to take weeks and maybe even some cases months to get to the other side. What we don’t want you to do is take years, which tends to be our default timeline for solving hard problems.

CURT NICKISCH: So you say to start with identifying the problem that’s holding you back, seems kind of obvious. But where do companies go right and wrong with this first step of just identifying the problem that’s holding you back?

ANNE MORRISS: And our goal is that all of these are going to feel obvious in retrospect. The problem is we skip over a lot of these steps and this is why we wanted to underline them. So this one is really rooted in our observation and I think the pattern of our species that we tend to be overconfident in the quality of our thoughts, particularly when it comes to diagnosing problems.

And so we want to invite you to start in a very humble and curious place, which tends not to be our default mode when we’re showing up for work. We convince ourselves that we’re being paid for our judgment. That’s exactly what gets reinforced everywhere. And so we tend to counterintuitively, given what we just talked about, we tend to move too quickly through the diagnostic phase.

CURT NICKISCH: “I know what to do, that’s why you hired me.”

ANNE MORRISS: Exactly. “I know what to do. That’s why you hired me. I’ve seen this before. I have a plan. Follow me.” We get rewarded for the expression of confidence and clarity. And so what we’re inviting people to do here is actually pause and really lean into what are the root causes of the problem you’re seeing? What are some alternative explanations? Let’s get into dialogue with the people who are also impacted by the problem before we start running down the path of solving it.

CURT NICKISCH: So what do you recommend for this step, for getting to the root of the problem? What are questions you should ask? What’s the right thought process? What do you do on Monday of the week?

ANNE MORRISS: In our experience of doing this work, people tend to undervalue the power of conversation, particularly with other people in the organization. So we will often advocate putting together a team of problem solvers, make it a temporary team, really pull in people who have a particular perspective on the problem and create the space, make it as psychologically safe as you can for people to really, as Chris Argyris so beautifully articulated, discuss the undiscussable.

And so the conditions for that are going to look different in every organization depending on the problem, but if you can get a space where smart people who have direct experience of a problem are in a room and talking honestly with each other, you can make an extraordinary amount of progress, certainly in a day.

CURT NICKISCH: Yeah, that gets back to the trust piece.

ANNE MORRISS: Definitely.

CURT NICKISCH: How do you like to start that meeting, or how do you like to talk about it? I’m just curious what somebody on that team might hear in that meeting, just to get the sense that it’s psychologically safe, you can discuss the undiscussable and you’re also focusing on the identification part. What’s key to communicate there?

ANNE MORRISS: Yeah. Well, we sometimes encourage people to do a little bit of data gathering before those conversations. So the power of a quick anonymous survey around whatever problem you’re solving, but also be really thoughtful about the questions you’re going to ask in the moment. So a little bit of preparation can go a long way and a little bit of thoughtfulness about the power dynamic. So who’s going to walk in there with license to speak and who’s going to hold back? So being thoughtful about the agenda, about the questions you’re asking about the room, about the facilitation, and then courage is a very infectious emotion.

So if you can early on create the conditions for people to show up bravely in that conversation, then the chance that you’re going to get good information and that you’re going to walk out of that room with new insight in the problem that you didn’t have when you walked in is extraordinarily high.

CURT NICKISCH: Now, in those discussions, you may have people who have different perspectives on what the problem really is. They also bear different costs of addressing the problem or solving it. You talked about the power dynamic, but there’s also an unfairness dynamic of who’s going to actually have to do the work to take care of it, and I wonder how you create a culture in that meeting where it’s the most productive?

ANNE MORRISS: For sure, the burden of work is not going to be equitably distributed around the room. But I would say, Curt, the dynamic that we see most often is that people are deeply relieved that hard problems are being addressed. So it really can create, and more often than not in our experience, it does create this beautiful flywheel of action, creativity, optimism. Often when problems haven’t been addressed, there is a fair amount of anxiety in the organization, frustration, stagnation. And so credible movement towards action and progress is often the best antidote. So even if the plan isn’t super clear yet, if it’s credible, given who’s in the room and their decision rights and mandate, if there’s real momentum coming out of that to make progress, then that tends to be deeply energizing to people.

CURT NICKISCH: I wonder if there’s an organization that you’ve worked with that you could talk about how this rolled out and how this took shape?

ANNE MORRISS: When we started working with Uber, that was wrestling with some very public issues of culture and trust with a range of stakeholders internally, the organization, also external, that work really started with a campaign of listening and really trying to understand where trust was breaking down from the perspective of these stakeholders?

So whether it was female employees or regulators or riders who had safety concerns getting into the car with a stranger. This work, it starts with an honest internal dialogue, but often the problem has threads that go external. And so bringing that same commitment to curiosity and humility and dialogue to anyone who’s impacted by the problem is the fastest way to surface what’s really going on.

CURT NICKISCH: There’s a step in this process that you lay out and that’s communicating powerfully as a leader. So we’ve heard about listening and trust building, but now you’re talking about powerful communication. How do you do this and why is it maybe this step in the process rather than the first thing you do or the last thing you do?

ANNE MORRISS: So in our process, again, it’s the days of the week. On Monday you figured out the problem. Tuesday you really got into the sandbox in figuring out what a good enough plan is for building trust. Wednesday, step three, you made it better. You created an even better plan, bringing in new perspectives. Thursday, this fourth step is the day we’re saying you got to go get buy-in. You got to bring other people along. And again, this is a step where we see people often underinvest in the power and payoff of really executing it well.

CURT NICKISCH: How does that go wrong?

ANNE MORRISS: Yeah, people don’t know the why. Human behavior and the change in human behavior really depends on a strong why. It’s not just a selfish, “What’s in it for me?” Although that’s helpful, but where are we going? I may be invested in a status quo and I need to understand, okay, if you’re going to ask me to change, if you’re going to invite me into this uncomfortable place of doing things differently, why am I here? Help me understand it and articulate the way forward and language that not only I can understand, but also that’s going to be motivating to me.

CURT NICKISCH: And who on my team was part of this process and all that kind of stuff?

ANNE MORRISS: Oh, yeah. I may have some really important questions that may be in the way of my buy-in and commitment to this plan. So certainly creating a space where those questions can be addressed is essential. But what we found is that there is an architecture of a great change story, and it starts with honoring the past, honoring the starting place. Sometimes we’re so excited about the change and animated about the change that what has happened before or what is even happening in the present tense is low on our list of priorities.

Or we want to label it bad, because that’s the way we’ve thought about the change, but really pausing and honoring what came before you and all the reasonable decisions that led up to it, I think can be really helpful to getting people emotionally where you want them to be willing to be guided by you. Going back to Uber, when Dara Khosrowshahi came in.

CURT NICKISCH: This is the new CEO.

ANNE MORRISS: The new CEO.

CURT NICKISCH: Replaced Travis Kalanick, the founder and first CEO, yeah.

ANNE MORRISS: Yeah, and had his first all-hands meeting. One of his key messages, and this is a quote, was that he was going to retain the edge that had made Uber, “A force of nature.” And in that meeting, the crowd went wild because this is also a company that had been beaten up publicly for months and months and months, and it was a really powerful choice. And his predecessor, Travis was in the room, and he also honored Travis’ incredible work and investment in bringing the company to the place where it was.

And I would use words like grace to also describe those choices, but there’s also an incredible strategic value to naming the starting place for everybody in the room because in most cases, most people in that room played a role in getting to that starting place, and you’re acknowledging that.

CURT NICKISCH: You can call it grace. Somebody else might call it diplomatic or strategic. But yeah, I guess like it or not, it’s helpful to call out and honor the complexity of the way things have been done and also the change that’s happening.

ANNE MORRISS: Yeah, and the value. Sometimes honoring the past is also owning what didn’t work or what wasn’t working for stakeholders or segments of the employee team, and we see that around culture change. Sometimes you’ve got to acknowledge that it was not an equitable environment, but whatever the worker, everyone in that room is bringing that pass with them. So again, making it discussable and using it as the jumping off place is where we advise people to start.

Then you’ve earned the right to talk about the change mandate, which we suggest using clear and compelling language about the why. “This is what happened, this is where we are, this is the good and the bad of it, and here’s the case for change.”

And then the last part, which is to describe a rigorous and optimistic way forward. It’s a simple past, present, future arc, which will be familiar to human beings. We love stories as human beings. It’s among the most powerful currency we have to make sense of the world.

CURT NICKISCH: Yeah. Chronological is a pretty powerful order.

ANNE MORRISS: Right. But again, the change leaders we see really get it right, are investing an incredible amount of time into the storytelling part of their job. Ursula Burns, the Head of Xerox is famous for the months and years she spent on the road just telling the story of Xerox’s change, its pivot into services to everyone who would listen, and that was a huge part of her success.

CURT NICKISCH: So Friday or your fifth step, you end with empowering teams and removing roadblocks. That seems obvious, but it’s critical. Can you dig into that a little bit?

ANNE MORRISS: Yeah. Friday is the fun day. Friday’s the release of energy into the system. Again, you’ve now earned the right to go fast. You have a plan, you’re pretty confident it’s going to work. You’ve told the story of change the organization, and now you get to sprint. So this is about really executing with urgency, and it’s about a lot of the tactics of speed is where we focus in the book. So the tactics of empowerment, making tough strategic trade-offs so that your priorities are clear and clearly communicated, creating mechanisms to fast-track progress. At Etsy, CEO Josh Silverman, he labeled these projects ambulances. It’s an unfortunate metaphor, but it’s super memorable. These are the products that get to speed out in front of the other ones because the stakes are high and the clock is sticking.

CURT NICKISCH: You pull over and let it go by.

ANNE MORRISS: Yeah, exactly. And so we have to agree as an organization on how to do something like that. And so we see lots of great examples both in young organizations and big complex biotech companies with lots of regulatory guardrails have still found ways to do this gracefully.

And I think we end with this idea of conflict debt, which is a term we really love. Leanne Davey, who’s a team scholar and researcher, and anyone in a tech company will recognize the idea of tech debt, which is this weight the organization drags around until they resolve it. Conflict debt is a beautiful metaphor because it is this weight that we drag around and slows us down until we decide to clean it up and fix it. The organizations that are really getting speed right have figured out either formally or informally, how to create an environment where conflict and disagreements can be gracefully resolved.

CURT NICKISCH: Well, let’s talk about this speed more, right? Because I think this is one of those places that maybe people go wrong or take too long, and then you lose the awareness of the problem, you lose that urgency. And then that also just makes it less effective, right? It’s not just about getting the problem solved as quickly as possible. It’s also just speed in some ways helps solve the problem.

ANNE MORRISS: Oh, yeah. It really is the difference between imagining the change you want to lead and really being able to bring it to life. Speed is the thing that unlocks your ability to lead change. It needs a foundation, and that’s what Monday through Thursday is all about, steps one through four, but the finish line is executing with urgency, and it’s that urgency that releases the system’s energy, that communicates your priorities, that creates the conditions for your team to make progress.

CURT NICKISCH: Moving fast is something that entrepreneurs and tech companies certainly understand, but there’s also this awareness that with big companies, the bigger the organization, the harder it is to turn the aircraft carrier around, right? Is speed relative when you get at those levels, or do you think this is something that any company should be able to apply equally?

ANNE MORRISS: We think this applies to any company. The culture really lives at the level of team. So we believe you can make a tremendous amount of progress even within your circle of control as a team leader. I want to bring some humility to this and careful of words like universal, but we do think there’s some universal truths here around the value of speed, and then some of the byproducts like keeping fantastic people. Your best people want to solve problems, they want to execute, they want to make progress and speed, and the ability to do that is going to be a variable in their own equation of whether they stay or they go somewhere else where they can have an impact.

CURT NICKISCH: Right. They want to accomplish something before they go or before they retire or finish something out. And if you’re able to just bring more things on the horizon and have it not feel like it’s going to be another two years to do something meaningful.

ANNE MORRISS: People – I mean, they want to make stuff happen and they want to be around the energy and the vitality of making things happen, which again, is also a super infectious phenomenon. One of the most important jobs of a leader, we believe, is to set the metabolic pace of their teams and organizations. And so what we really dig into on Friday is, well, what does that look like to speed something up? What are the tactics of that?

CURT NICKISCH: I wonder if that universal truth, that a body in motion stays in motion applies to organizations, right? If an organization in motion stays in motion, there is something to that.

ANNE MORRISS: Absolutely.

CURT NICKISCH: Do you have a favorite client story to share, just where you saw speed just become a bit of a flywheel or just a positive reinforcement loop for more positive change at the organization?

ANNE MORRISS: Yeah. We work with a fair number of organizations that are on fire. We do a fair amount of firefighting, but we also less dramatically do a lot of fire prevention. So we’re brought into organizations that are working well and want to get better, looking out on the horizon. That work is super gratifying, and there is always a component of, well, how do we speed this up?

What I love about that work is there’s often already a high foundation of trust, and so it’s, well, how do we maintain that foundation but move this flywheel, as you said, even faster? And it’s really energizing because often there’s a lot of pent-up energy that… There’s a lot of loyalty to the organization, but often it’s also frustration and pent-up energy. And so when that gets released, when good people get the opportunity to sprint for the first time in a little while, it’s incredibly energizing, not just for us, but for the whole organization.

CURT NICKISCH: Anne, this is great. I think finding a way to solve problems better but also faster is going to be really helpful. So thanks for coming on the show to talk about it.

ANNE MORRISS:  Oh, Curt, it was such a pleasure. This is my favorite conversation. I’m delighted to have it anytime.

HANNAH BATES: That was entrepreneur, leadership coach, and author Anne Morriss – in conversation with Curt Nickisch on HBR IdeaCast.

We’ll be back next Wednesday with another hand-picked conversation about business strategy from Harvard Business Review. If you found this episode helpful, share it with your friends and colleagues, and follow our show on Apple Podcasts, Spotify, or wherever you get your podcasts. While you’re there, be sure to leave us a review.

When you’re ready for more podcasts, articles, case studies, books, and videos with the world’s top business and management experts, you’ll find it all at HBR.org.

This episode was produced by Mary Dooe, Anne Saini, and me, Hannah Bates. Ian Fox is our editor. Special thanks to Rob Eckhardt, Maureen Hoch, Erica Truxler, Ramsey Khabbaz, Nicole Smith, Anne Bartholomew, and you – our listener. See you next week.

  • Subscribe On:

Latest in this series

This article is about strategy.

  • Decision making and problem solving
  • Strategy execution
  • Leadership and managing people
  • Collaboration and teams
  • Trustworthiness
  • Organizational culture

Partner Center

  • Trending Now
  • Foundational Courses
  • Data Science
  • Practice Problem
  • Machine Learning
  • System Design
  • DevOps Tutorial

Domain and Range of a Function

Understand the concepts of domain and range of a function with this comprehensive guide. Knowing how to determine the domain and range is crucial for analyzing and interpreting functions in mathematics.

Key Takeaways

Introduction to domain and range.

  • Definition of domain and range.
  • Importance of understanding the domain and range in mathematical functions.

How to Determine the Domain

  • Steps to find the domain of a function.
  • Examples of common functions and their domains.

How to Determine the Range

  • Steps to find the range of a function.
  • Examples of common functions and their ranges.

Applications of Domain and Range

  • Real-life applications of domain and range in various fields.
  • How understanding domain and range can aid in problem-solving.

The domain of a function is the complete set of possible input values (independent variable) that allow the function to work. The range of a function is the complete set of possible output values (dependent variable) that result from using the function. Understanding these concepts is essential for graphing functions and solving mathematical problems.

Steps to Find the Domain

  • Identify the Function : Start by understanding the type of function you are dealing with, such as linear, quadratic, polynomial, rational, etc.
  • Analyze Constraints : Determine any restrictions on the input values. For example, values that make the denominator zero in a rational function or negative values under a square root in a real-valued function.
  • Set Notation : Express the domain using interval notation or set notation.
  • Linear Functions : The domain is all real numbers.
  • Quadratic Functions : The domain is all real numbers.
  • Rational Functions : Exclude values that make the denominator zero.
  • Square Root Functions : Include only values that make the expression under the square root non-negative.

Steps to Find the Range

  • Identify the Function : Understand the type of function you are analyzing.
  • Determine the Behavior : Analyze how the function behaves as the input values change, considering both end behavior and any critical points.
  • Solve for Output Values : Determine the set of all possible output values based on the input values within the domain.
  • Linear Functions : The range is all real numbers.
  • Quadratic Functions : The range is all real numbers greater than or equal to the vertex's y-coordinate (for upward-facing parabolas) or less than or equal to the vertex's y-coordinate (for downward-facing parabolas).
  • Rational Functions : Determine the horizontal asymptotes or use limits to find the range.
  • Square Root Functions : The range includes only non-negative values.

Real-life Applications

  • Engineering : Analyzing stresses and strains in materials.
  • Economics : Understanding demand and supply functions.
  • Science : Modeling population growth or radioactive decay.

Problem-solving

Knowing the domain and range helps in solving equations, optimizing functions, and understanding the behavior of different mathematical models.

By mastering the concepts of domain and range, you can enhance your mathematical skills and apply them to various real-world problems.

For a detailed step-by-step guide, visit the full article at https://www.geeksforgeeks.org/domain-and-range-of-function/ .

Video Thumbnail

IMAGES

  1. Six Steps to Solving a Programming Problem Infographic

    steps of problem solving in programming

  2. 6 Ways to Improve Your Programming Problem Solving

    steps of problem solving in programming

  3. Tips to Improve Problem-Solving Skills in Programming

    steps of problem solving in programming

  4. 5 step problem solving method

    steps of problem solving in programming

  5. 7 Step Problem Solving Method

    steps of problem solving in programming

  6. The four stages of problem solving, adapted from the “integrated model

    steps of problem solving in programming

VIDEO

  1. POLYA'S 4 STEPS PROBLEM SOLVING

  2. Double in C

  3. FOUR STEPS PROBLEM-SOLVING STRATEGY BY POLYA

  4. Number Theory -GCD -LCM-Sieve of eratosthenes- Prime factorization شرح

  5. Prefix sum array شرح || Problem solving

  6. A Simple Technique to Solve Coding Problems

COMMENTS

  1. How to Solve Coding Problems with a Simple Four Step Method

    In this post, we've gone over the four-step problem-solving strategy for solving coding problems. Let's review them here: Step 1: understand the problem. Step 2: create a step-by-step plan for how you'll solve it. Step 3: carry out the plan and write the actual code.

  2. 10 Steps to Solving a Programming Problem

    The goal is to take all the even numbers and return them in an array. If there are no even numbers, return an empty array. 2. Work through the problem manually with at least three sets of sample data. Take out a piece of paper and work through the problem manually.

  3. What is Problem Solving? An Introduction

    Problem solving, in the simplest terms, is the process of identifying a problem, analyzing it, and finding the most effective solution to overcome it. For software engineers, this process is deeply embedded in their daily workflow. It could be something as simple as figuring out why a piece of code isn't working as expected, or something as ...

  4. How to Solve Coding Problems: Step-by-Step Guide (2024)

    Plan out Algorithm Steps. For effective problem-solving, it is crucial to plan out the steps of your algorithm before writing actual code. Pseudocode helps break down the problem into smaller, manageable steps, making it easier to implement the solution in the chosen programming language. Visualize solution flow

  5. PDF Problem Solving Basics and Computer Programming

    We can do this in four steps. 1. Identify all of the nouns in the sentence. Given the 3 dimensions of a box (length, width, and height), calculate the volume. The nouns in the problem specification identify descriptions of information that you will need to either identify or keep track of.

  6. Solving the Puzzle: Strategies for Effective Problem-Solving in Programming

    The process of problem-solving in programming involves several key steps that guide programmers towards effective solutions. These steps include: Analyzing the Problem: Before diving into writing code, it's important to thoroughly understand the problem at hand. This includes identifying the inputs, expected outputs, edge cases, and any ...

  7. 5 Steps to Solving Programming Problems

    If there are no even numbers, return an empty array. 2. Manually solve the problem with at least three sets of sample data. Take out a piece of paper and work through the problem manually. Think of at least three sets of sample data you can use. Consider corner and edge cases as well.

  8. Hands-on Tutorial: How To Improve Your Problem-Solving Skills As A

    Programming is ultimately problem-solving. We only apply the programming language to express how we've thought about a problem and the approach we're using to solve it. ... The first step to solving any problem is to understand the problem being solved. This means you're able to articulate the problem fully in your own words.

  9. Problem Solving

    The programming languages and tools they use are secondary to this fundamental skill. From his book, "Think Like a Programmer", V. Anton Spraul defines problem solving in programming as: Problem solving is writing an original program that performs a particular set of tasks and meets all stated constraints.

  10. How to Develop Problem Solving Skills in Programming

    Problem solving in programming skills is much needed for a person and holds a major advantage. For every question, there are specific steps to be followed to get a perfect solution. By using those steps, it is possible to find a solution quickly. The above section is covered with an explanation of problem solving in programming skills.

  11. UNIT 1: How to Think Like an Engineer

    The Process of Computational Problem Solving. Computational problem solving does not simply involve the act of computer programming. It is a process, with programming being only one of the steps. Before a program is written, a design for the program must be developed (the algorithm).

  12. PDF Computer Programming Problem Solving Process

    How to begin the problem-solving process . Programmers must solve many different types of problems. One problem that students often encounter in programming classes is how to find the lowest or highest value in a list of numbers. Review the following example, and note the steps a programmer could take to solve the problem. Example problem: Find ...

  13. The Beginner Programmer's guide to Problem Solving [With Example]

    Step 3: Connect the dots (Integration) You have solved individual problems. Now it is time to connect the dots by connecting the individual solution. Identify those steps which will make the solution or the program complete. Typically in programming, the dots are connected by passing data that is stored in variables.

  14. How To Approach A Coding Problem

    These steps you need to follow while solving a problem: - Understand the question, read it 2-3 times. - Take an estimate of the required complexity. - find, edge cases based on the constraints. - find a brute-force solution. ensure it will pass. - Optimize code, ensure, and repeat this step. - Dry-run your solution (pen& paper) on ...

  15. Programming Tutorial

    Programming involves several key steps: Problem definition: Clearly define the problem you want to solve and what you want the program to achieve. Algorithm design: Develop a step-by-step procedure for solving the problem. Coding: Translate the algorithm into a programming language using a text editor or integrated development environment (IDE).

  16. Problem Solving in Python

    An algorithm is a process or set of rules to be followed while performing calculations or other problem-solving operations. It is simply a set of steps to accomplish a certain task. In this article, we will discuss 5 major steps for efficient problem-solving. These steps are: Understanding the Problem; Exploring Examples; Breaking the Problem Down

  17. Basic Programming Problems

    Learn Programming - How To Code. In the world of programming, mastering the fundamentals is key to becoming a proficient developer.In this article, we will explore a variety of basic programming problems that are essential for every aspiring coder to understand. By delving into these foundational challenges, you will gain valuable insights into problem-solving techniques and build a strong ...

  18. What is Problem Solving? Steps, Process & Techniques

    Finding a suitable solution for issues can be accomplished by following the basic four-step problem-solving process and methodology outlined below. Step. Characteristics. 1. Define the problem. Differentiate fact from opinion. Specify underlying causes. Consult each faction involved for information. State the problem specifically.

  19. How to Use Algorithms to Solve Problems?

    There must be "Start" as the first step and "End" as the last step of the algorithm. Let's take an example to make a cup of tea, Step 1: Start. Step 2: Take some water in a bowl. Step 3: Put the water on a gas burner. Step 4: Turn on the gas burner. Step 5: Wait for some time until the water is boiled.

  20. ISTE

    Step 2: Find a solution. To find or plan the solution to the problem identified in Step 1, students can either create a flowchart or write pseudocode. Experienced programmers can and will use either of these methods to convey program development to clients, teachers, etc. A flowchart is a step-by-step solution to a problem that uses a pictorial ...

  21. A Better Framework for Solving Tough Problems

    In this episode, she outlines a five-step process for solving any problem. Some, she says, can be solved in a week, while others take much longer. She also explains why starting with trust and ...

  22. CBSE Class 11

    Under problem-solving methodology, we will see a step by step solution for a problem. These steps closely resemble the software life cycle. A software life cycle involves several stages in a program's life cycle. These steps can be used by any tyro programmer to solve a problem in the most efficient way ever. The several steps of this cycle ...

  23. EKM: An exact, polynomial-time algorithm for the $K$-medoids problem

    EKM is developed according to recent advances in transformational programming and combinatorial generation, using formal program derivation steps. The derived algorithm is provably correct by construction.

  24. Domain and Range of a Function

    It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions. Videos. May 28, 2024 0 ... Steps to find the domain of a function. ... Problem-solving. Knowing the domain and range helps in solving equations, optimizing functions, and ...