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

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?

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.

How to think like a programmer — lessons in problem solving

How to think like a programmer — lessons in problem solving

by Richard Reis

aNP21-ICMABUCyfdi4Pys7P0D2wiZqTd3iRY

If you’re interested in programming, you may well have seen this quote before:

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

You probably also wondered what does it mean, exactly, to think like a programmer? And how do you do it??

Essentially, it’s all about a more effective way for problem solving .

In this post, my goal is to teach you that way.

By the end of it, you’ll know exactly what steps to take to be a better problem-solver.

Why is this important?

Problem solving is the meta-skill.

We all have problems. Big and small. How we deal with them is sometimes, well…pretty random.

Unless you have a system, this is probably how you “solve” problems (which is what I did when I started coding):

  • Try a solution.
  • If that doesn’t work, try another one.
  • If that doesn’t work, repeat step 2 until you luck out.

Look, sometimes you luck out. But that is the worst way to solve problems! And it’s a huge, huge waste of time.

The best way involves a) having a framework and b) practicing it.

“Almost all employers prioritize problem-solving skills first.
Problem-solving skills are almost unanimously the most important qualification that employers look for….more than programming languages proficiency, debugging, and system design.
Demonstrating computational thinking or the ability to break down large, complex problems is just as valuable (if not more so) than the baseline technical skills required for a job.” — Hacker Rank ( 2018 Developer Skills Report )

Have a framework

To find the right framework, I followed the advice in Tim Ferriss’ book on learning, “ The 4-Hour Chef ”.

It led me to interview two really impressive people: C. Jordan Ball (ranked 1st or 2nd out of 65,000+ users on Coderbyte ), and V. Anton Spraul (author of the book “ Think Like a Programmer: An Introduction to Creative Problem Solving ”).

I asked them the same questions, and guess what? Their answers were pretty similar!

Soon, you too will know them.

Sidenote: this doesn’t mean they did everything the same way. Everyone is different. You’ll be different. But if you start with principles we all agree are good, you’ll get a lot further a lot quicker.

“The biggest mistake I see new programmers make is focusing on learning syntax instead of learning how to solve problems.” — V. Anton Spraul

So, what should you do when you encounter a new problem?

Here are the steps:

1. Understand

Know exactly what is being asked. Most hard problems are hard because you don’t understand them (hence why this is the first step).

How to know when you understand a problem? When you can explain it in plain English.

Do you remember being stuck on a problem, you start explaining it, and you instantly see holes in the logic you didn’t see before?

Most programmers know this feeling.

This is why you should write down your problem, doodle a diagram, or tell someone else about it (or thing… some people use a rubber duck ).

“If you can’t explain something in simple terms, you don’t understand it.” — Richard Feynman

Don’t dive right into solving without a plan (and somehow hope you can muddle your way through). Plan your solution!

Nothing can help you if you can’t write down the exact steps.

In programming, this means don’t start hacking straight away. Give your brain time to analyze the problem and process the information.

To get a good plan, answer this question:

“Given input X, what are the steps necessary to return output Y?”

Sidenote: Programmers have a great tool to help them with this… Comments!

Pay attention. This is the most important step of all.

Do not try to solve one big problem. You will cry.

Instead, break it into sub-problems. These sub-problems are much easier to solve.

Then, solve each sub-problem one by one. Begin with the simplest. Simplest means you know the answer (or are closer to that answer).

After that, simplest means this sub-problem being solved doesn’t depend on others being solved.

Once you solved every sub-problem, connect the dots.

Connecting all your “sub-solutions” will give you the solution to the original problem. Congratulations!

This technique is a cornerstone of problem-solving. Remember it (read this step again, if you must).

“If I could teach every beginning programmer one problem-solving skill, it would be the ‘reduce the problem technique.’
For example, suppose you’re a new programmer and you’re asked to write a program that reads ten numbers and figures out which number is the third highest. For a brand-new programmer, that can be a tough assignment, even though it only requires basic programming syntax.
If you’re stuck, you should reduce the problem to something simpler. Instead of the third-highest number, what about finding the highest overall? Still too tough? What about finding the largest of just three numbers? Or the larger of two?
Reduce the problem to the point where you know how to solve it and write the solution. Then expand the problem slightly and rewrite the solution to match, and keep going until you are back where you started.” — V. Anton Spraul

By now, you’re probably sitting there thinking “Hey Richard... That’s cool and all, but what if I’m stuck and can’t even solve a sub-problem??”

First off, take a deep breath. Second, that’s fair.

Don’t worry though, friend. This happens to everyone!

The difference is the best programmers/problem-solvers are more curious about bugs/errors than irritated.

In fact, here are three things to try when facing a whammy:

  • Debug: Go step by step through your solution trying to find where you went wrong. Programmers call this debugging (in fact, this is all a debugger does).
“The art of debugging is figuring out what you really told your program to do rather than what you thought you told it to do.”” — Andrew Singer
  • Reassess: Take a step back. Look at the problem from another perspective. Is there anything that can be abstracted to a more general approach?
“Sometimes we get so lost in the details of a problem that we overlook general principles that would solve the problem at a more general level. […]
The classic example of this, of course, is the summation of a long list of consecutive integers, 1 + 2 + 3 + … + n, which a very young Gauss quickly recognized was simply n(n+1)/2, thus avoiding the effort of having to do the addition.” — C. Jordan Ball

Sidenote: Another way of reassessing is starting anew. Delete everything and begin again with fresh eyes. I’m serious. You’ll be dumbfounded at how effective this is.

  • Research: Ahh, good ol’ Google. You read that right. No matter what problem you have, someone has probably solved it. Find that person/ solution. In fact, do this even if you solved the problem! (You can learn a lot from other people’s solutions).

Caveat: Don’t look for a solution to the big problem. Only look for solutions to sub-problems. Why? Because unless you struggle (even a little bit), you won’t learn anything. If you don’t learn anything, you wasted your time.

Don’t expect to be great after just one week. If you want to be a good problem-solver, solve a lot of problems!

Practice. Practice. Practice. It’ll only be a matter of time before you recognize that “this problem could easily be solved with <insert concept here>.”

How to practice? There are options out the wazoo!

Chess puzzles, math problems, Sudoku, Go, Monopoly, video-games, cryptokitties, bla… bla… bla….

In fact, a common pattern amongst successful people is their habit of practicing “micro problem-solving.” For example, Peter Thiel plays chess, and Elon Musk plays video-games.

“Byron Reeves said ‘If you want to see what business leadership may look like in three to five years, look at what’s happening in online games.’
Fast-forward to today. Elon [Musk], Reid [Hoffman], Mark Zuckerberg and many others say that games have been foundational to their success in building their companies.” — Mary Meeker ( 2017 internet trends report )

Does this mean you should just play video-games? Not at all.

But what are video-games all about? That’s right, problem-solving!

So, what you should do is find an outlet to practice. Something that allows you to solve many micro-problems (ideally, something you enjoy).

For example, I enjoy coding challenges. Every day, I try to solve at least one challenge (usually on Coderbyte ).

Like I said, all problems share similar patterns.

That’s all folks!

Now, you know better what it means to “think like a programmer.”

You also know that problem-solving is an incredible skill to cultivate (the meta-skill).

As if that wasn’t enough, notice how you also know what to do to practice your problem-solving skills!

Phew… Pretty cool right?

Finally, I wish you encounter many problems.

You read that right. At least now you know how to solve them! (also, you’ll learn that with every solution, you improve).

“Just when you think you’ve successfully navigated one obstacle, another emerges. But that’s what keeps life interesting.[…]
Life is a process of breaking through these impediments — a series of fortified lines that we must break through.
Each time, you’ll learn something.
Each time, you’ll develop strength, wisdom, and perspective.
Each time, a little more of the competition falls away. Until all that is left is you: the best version of you.” — Ryan Holiday ( The Obstacle is the Way )

Now, go solve some problems!

And best of luck ?

Special thanks to C. Jordan Ball and V. Anton Spraul . All the good advice here came from them.

Thanks for reading! If you enjoyed it, test how many times can you hit in 5 seconds. It’s great cardio for your fingers AND will help other people see the story.

If this article was helpful, share it .

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

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

matheusmms031 profile image

Os bons hábitos do uso das IAs na bolha DEV

Matheus Magalhães - Jun 12

abhayit2000 profile image

An Expert Guide to Enhanced Mobile Testing with HeadSpin Automation

Abhay Chaturvedi - Jun 12

jankapunkt profile image

MeteorJS 3.0 major impact estimated for July 2024 ☄️ - here is all you need to know 🧐

Jan Küster - Jun 24

robertobutti profile image

Validating JSON with JSON Schema and PHP

Roberto B. - Jun 24

DEV Community

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

what are the steps in problem solving in programming

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

what are the steps in problem solving in programming

  • View Unanswered Questions
  • View All Questions
  • View C# questions
  • View C++ questions
  • View Visual Basic questions
  • View Javascript 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

what are the steps in problem solving in programming

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

what are the steps in 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

to use this message board.
  Layout   Per page    
First Prev Next
21-Sep-15 0:33 21-Sep-15 0:33 
First note that there are some typos ('1' characters all over the place). I presume this happened on each place where you wanted to write an exclamation mark.

For example:

3. I will never give up on any problem that is put at me, I will ask for help if required.

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.

You need to understand your problem clearly before even trying to solve it .

Etc...

Nevertheless it is a nice read and I absolutely agree with you.
The whole "trick" to solving any given problem is understanding it, breaking it down to a smaller portions and tackling each portion separately one at the time.

This should feel quite natural to any OOP developer, essentially that is what object-oriented is all about. Now I don't know about any mental block, but what I noticed is that if a person has difficulties with problem solving he also has difficulties with object-oriented paradigm.
I've observed this with many of our newcomers, the problem is that without a real life problems and their solutions typically the newcomers have difficulties in picturing the required objects and their relationship and how should they communicate with each other.
But this skill set can be fairly easily acquired, it all comes down to experience, as you mentioned the more problems you solve the better you become. That is why I like to assign our newcomers with some "homework" tests for practising, for example something like ( ). I really encourage anyone that is working on improving his problem solving skills to practice with small programming challenges. Each challenge defines a small portion so this will help to identify what the portion is in any bigger, more complex, problem.


·  
30-Oct-14 21:24 30-Oct-14 21:24 
I'm new to C# and I'm currently having difficulties with my new job. Thank you for this, now I can maximize my time thinking about how to solve my problems!
·  
30-Oct-14 21:31 30-Oct-14 21:31 
Thank you mariecrisbetis. Glad my article is helping you out.

In fact, this is exactly my dream and vision for starting my .

Every beginner programmer should get off the blocks as quickly as possibly.
·  
30-Oct-14 21:34 30-Oct-14 21:34 
That is a good website for beginners like me. Thank you again for posting these kind of useful articles. You're great!
·  
30-Oct-14 21:37 30-Oct-14 21:37 
Thanks and welcome mate.
·  
29-Oct-14 23:24 29-Oct-14 23:24 
Interesting article.
I started programming in the COBOL area (yes I am that old).
My professor at that time learned us analysing the the problem using the the JSP methodiology.
The mean philosophy of JSP (Jackson Structured Programming)is that the structure of the problem is the structure of the program.
It started by describing the inpu and output in terma of sequences, iteration and selections (Dijkstra's concepts). Once you have that, the program is strucured such that the mapping beteem input and output structures can be reached...
·  
30-Oct-14 21:36 30-Oct-14 21:36 
Hi marc,

Thanks for your comments.

Yeah, I was just looking at JSP. Seems like an excellent approach to problem solving. In fact, I am from a Non-CS background, hence I had to form mental models (for concepts, problem solving, programming, etc.) on my own rather than studying these proven theories. It has turned out good so far.
·  
30-Oct-14 22:20 30-Oct-14 22:20 
Hello Rajaraman,

I started from a non-CS backgroud as well (I studied applied Economics and specialized later in Busines Informatics). Recently (last 5 years) I returned to psychology: I took an NLP course which is most of communication and our learning process. The leaning process in NLP is modelling and here we come back to your article. Quite amazing how everything is connected to everything.

Thanks for your feedback!

Regards,
Marc
·  
30-Oct-14 22:24 30-Oct-14 22:24 
Haha... That's true Marc. Everything in this world seemed connected in some way... (But we need to carefully analyze to figure out the connection).

I am also interested in learning psychology, but I dont think I can go for a full time course. Are you aware of any MOOCs for psychology that are good?
·  
30-Oct-14 23:22 30-Oct-14 23:22 
As a matter of fact I am involved in a project of social deprivation. In the project, the intention is to have budies for some unpreviledges. Those buddies need to be supported and have an education. There are some MOOCs in development to give that education. On one of them I quite intensively collaborated. Unfortunately they are in Dutch.

For NLP, a good starting point is 'NLP for dummies'.

Regards,
Marc
·  
31-Oct-14 2:53 31-Oct-14 2:53 
Oh ok.. Do let me know once they are in English. I would be interested.
·  
29-Oct-14 21:22 29-Oct-14 21:22 
my vote of 5.
Thanks Rajaraman sir..
·  
29-Oct-14 21:46 29-Oct-14 21:46 
Thank you Aarif
·  
29-Oct-14 9:01 29-Oct-14 9:01 
Rajarnam,

Thanks so much! This is great material and it reminds me that everyone struggles, but there is a solution.

Thanks again,
Steve
·  
29-Oct-14 21:45 29-Oct-14 21:45 
You're welcome Steve. And thanks for taking time to read.
·  
31-Oct-14 2:48 31-Oct-14 2:48 
Yes, I really enjoyed the article and learned a lot.

I give you a vote of 100!
·  
31-Oct-14 2:51 31-Oct-14 2:51 
Thank you mate !!
·  
28-Oct-14 23:45 28-Oct-14 23:45 
Good One
·  
Thank you Shememsha.
·  
Last Visit: 31-Dec-99 18:00     Last Update: 27-Jun-24 5:18

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

what are the steps in problem solving in programming

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:

NameDatePlace
Cohort starts on 9th Jul 2024,
Weekend batch
Your City
Cohort starts on 30th Jul 2024,
Weekend batch
Your City

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]

what are the steps in 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

what are the steps in 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.

1

List: 44, 14, 0, 1521, 89, 477

1521

2

List: 18, 4, 72, *, 31

Error (or no result)

3

List: 22, -9, 52

Error (or no result)

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,

variable is assigned the value 21
 variable is assigned the value ‘comp15’

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

variable is assigned the value 21
variable is assigned the value of 21+1 (22)

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.

1

numbers 0 and 859

sum is 859
product is 0

2

numbers -5 and 10

sum is 5
product is -50

3

numbers 12 and 3

sum is 15
product is 36

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.

1

choice ‘a’
numbers -12 and 32

answer is 20
terminate

2

choice ‘s’
numbers -2012 and 0

answer is 2012
terminate

3

choice ‘**’
numbers 8 and 4

answer is NONE
terminate

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.

1

salary of 0

tax is 0
terminate

2

salary of 75000

tax is 2500
terminate

3

salary of 120000

tax is 30000
terminate

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.

1

letter ‘z’

The character you typed is z.
Ask for another letter.

2

letter ‘8’

The character you typed is 8
Ask for another letter.

3

letter ‘q’

The character you typed is q.
Terminate.

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.

1

num_words 1
word ‘code’

The word you entered is ‘code’.
Terminate.

2

num_words 3
word ‘coding’

word ‘is’


word ‘fun’

The word you entered is ‘coding’.
Ask for another word.

The word you entered is ‘is’.
Ask for another word.

The word you entered is ‘fun’.
Terminate.

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.”
>= 0.9 A
>= 0.8 B
>= 0.7 C
>= 0.6 D
< 0.6 E
  • 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

Walkthrough

Programming problem solving walkthrough.

A programming problem solving walkthrough is a written guided description of the journey from a problem to a solution. It aims to teach how to solve programming problems in a methodical and thoughtful manner using the model. In other words, the knowledge to be learned is focused on the "how", and not on the programming language per se.

The walkthrough, as a teaching method, is based on two concepts: worked example from learning sciences and literate programming from computer science.

A worked example is a step-by-step demonstration of how to solve a problem. Learning scientists found out that worked examples are most effective for novices (i.e., the audience of a walkthrough), while performing problem-solving is more beneficial for experts. There are multiple ways of presenting and supporting worked examples , and one of the evidence-based techniques is to include sub-goal labeling, which is about labeling groups of steps in the worked example.

Literate programming by Donald E. Knuth is a programming paradigm in which a program is written as interspersed snippets of executable code and text. The text, which is written in ordinary human language, explains the logic of the code and explains the programmer's thoughts and decisions. Thus a program is perceived much more like an essay.

The walkthrough combines these two powerful ideas for learning the craft of problem solving by programming. It uses the programming problem solving model and its supplements to give a framework for establishing the learning objectives, as well as defining the walkthrough's structure and flow.

The learning objective of a walkthrough is rooted in one of the phases (for example, acquiring the ability to use a specific design strategy). That's in addition to the always-present learning objective of mastering the instrumentation of end-to-end problem solving .

Many times the solving process is hidden, and one gets only the final result, the executable code. Therefore, an essential feature of a walkthrough is making the reasoning explicit, as suggested by literate programming. In other words, it brings the solving process to the surface and documents the train of thought of the problem-solver as they go through each of the phases. In fact, a walkthrough aims to prompt self-explanation by the learners.

A similar but different flavor of a walkthrough is one that is developed by the learners. They choose a programming problem and fill in a provided walkthrough template. The learners improve their ability to solve problems by explicitly documenting their own process.

This page was written with Python in mind, with Jupyter Notebook that serves as the medium for the walkthrough. Notebooks are natural for literate programming , with their capability to mix text, media, and code in cells. Nevertheless, a walkthrough is a teaching method which is beyond one programming language or another, and it can also be developed as a source code file.

Few (opinionated) Principles and Practices

A walkthrough is an active learning activity. It is similar to a tutorial in the sense that it is most effective if the reader follows along by actually performing the tasks being described. In our particular case the tasks are based on the phases of the problem-solving model .

For example:

  • Reinterpret the Problem phase - suggest input-output instances.
  • Design a Solution phase - write about choosing a data structure, what attributes make it fit.

While it is important to focus on one particular phase so as not to overwhelm the learner, other phases should not be neglected. To keep the student engaged throughout the walkthrough it is suggested to use less demanding, yet active, tasks.

Tasks suggested by phase appear later on this page.

The walkthrough is designed to achieve teachable moments , in which it leads the learners to a point where they discover or apply a concept, an idea or a technique from the learning objectives.

At the same time a walkthrough must manage cognitive load , with a great focus on the external one.

The walkthrough is a "better version of reality" that focuses on the learning, and not on accurate journaling of the problem solving process . By its nature, this process is often messy and non-linear. Meanwhile, the goal of the walkthrough is to guide the learner through solving the problem in a logical and clear manner, without recording all the twists and turns. In that sense, the walkthrough is a "better version of reality", in which the actual steps are filtered and distilled to support the designer's learning objectives efficiently.

The text and code should be written in expository style . Even if a program has a hierarchical (tree) design, it this might not mean that this structure is the best for its development.

A problem should be solved and explored in a psychologically correct order , following the solver's "stream of consciousness" . The objective is to go through the process of solving, and a walkthrough inherently performs a "linearization" of this path. As Donald E. Knuth wrote:

My experiences have led me to believe that a person reading a program is likewise, ready to comprehend it by learning its various parts in approximately the order in which it was written.

The walkthrough is intended to be perceived as a dialogue with the learner . Of course, this is impossible due to the non-interactive format, but aimed as aspiration.

Walkthroughs are not stand alone but should be considered in context of a unit or a course. After the learners worked on the walkthrough, a wrap-up session (that might include a presentation or live coding of partial or complete solution) should take place.

Use of real-word problems or cover story can increase the motivation of the learners.

It is advised to limit the external permitted materials for the learners.

Checklist / Rubric

This is an opinionated checklist of all the points that a decent walkthrough should fulfill. It refers to the complete walkthrough after a learner performs all the tasks. It is up to the developer to decide which parts are already presented at the beginning and which are left to the learners.

  • Get something working and keep it working:
  • First writing code in cells, testing it and only then encapsulating into functions

Reinterpret the Problem

  • Rephrasing the problem statement in their own words
  • Writing the solution contract
  • Meaning and (Python) type
  • One or few input-output pairs of concrete instances (it doesn't need to be comprehensive right now, it is not the Test phase)

Design a Solution

  • Ultimately, a walkthrough should break down the problem into hierarchical sub-problems; in other words, it should present an outline of the solution decomposed into sub-problems.
  • Following the DRY (Don't Repeat Yourself ) design principle - Identifying repeating sub-problems
  • A mapping between the information in the problem/solution domain to a data-structure (either primitive or composed, flat or nested) in Python
  • Describing the meaning of the data structure, the relationship between its components and the required operation (a.k.a questions)
  • Transforming well the design into code
  • Pythonic Code - Python Idioms
  • Meaningful Names
  • Using Comments
  • Using Helper Functions when needed (e.g., for following DRY)
  • Black box (e.g., trivial cases, simplest non-trivial cases, edge cases, corner cases - but it is not mandatory to write the type)
  • White box - coverage / path-complete
  • Scenario - Using the language of the problem phase/domain
  • Instance - Concrete Input-Output pairs
  • The test case follows the simplicity principle - the instance(s) should be the simplest possible to test the scenario.
  • Following the empirical approach for debugging (reproduce, diagnose, fix, repeat, reflect)
  • Diagnose - Focus on reasoning on the available clues (e.g., the bug itself - input/output and trace-back, reading the code with a critical eye, using the print function)

Evaluate & Reflect

  • Functionality
  • Design & Code
  • Readability, Style & Documentation
  • Alignment between the presented problem solving process and the takeaways
  • Postmortem of the problem solving or debugging process
  • Self-debugging - what the programmer can learn from solving this problem.

Solution Program - Solving the Problem

  • Copy-paste and organize all the necessary code for a complete solution of the problem in one cell or py file, and execute it to solve the original problem. Note that it might require asking the learners to combine code snippets from different parts of the notebook.
  • The code in the solution section is self-contained for execution, and doesn't depend on other snippets of code from the previous steps.
  • This section also contains tests of the solution code.

Tips for Developing a Walkthrough

The Carpentries Curriculum Development Handbook is an excellent resource for how to develop a curriculum in computing and what it says is equally applicable to developing a walkthrough.

First of all, set the learning objectives using the programming problem solving model terminology.

Form a problem - choose an algorithmic one or real-world one.

Solve the problem, document your process based on the model, pay attention to your mistakes and bugs.

Reflect on your problem solving process and try to distill it into steps and teachable moments.

Refactor your code and remove clutter. While it doesn't have to be the best possible, make sure to adjust for the required ability of your learners.

Write an outline of the walkthrough and embed your code in the relevant sections. Validate it with a checklist .

Decide what tasks the learners should do, making sure they align with the learning objectives.

Write the complete text of the walkthrough that guides the learners. It is advised to use the plural first person pronoun "we".

Run a pilot of the walkthrough on a small group of learners.

Repeat and improve!

Suggested Tasks by Phase

  • Phrase the problem in your own words
  • Write three examples of input-output pairs for the problem
  • Write the solution of the problem or of a function (in the docstring)
  • Write a design (either as text or as a diagram) for a problem or a sub-problem
  • Choose a data structure and reason about it
  • Describe how to solve the problem "by hand" for one specific input
  • Solve a Parson's Puzzle (or the two-dimensional flavor ). It can be created and embedded in Jupyter Notebook with http://parsons.problemsolving.io
  • Write code according to a design (either done by the learner or given in the walkthrough)
  • Draw an environment diagram
  • Answer questions about it
  • Write a docstring to a function
  • Give meaningful names for variables in the code
  • Extract its design (e.g., write a "design tweet" with a maximum of 240 characters)
  • Discuss its design - why did the solver choose that particular design and not another, especially pay attention to the data structures
  • Write test cases for the problem or function
  • Fix a bug in a given piece of code
  • Describe a bug you had while solving the problem, and explain how you fixed it
  • Evaluate a given piece of code
  • Evaluate your code
  • Reflect on your problem solving process

Repeat & Improve

  • Refactor a given piece of code (e.g., because of speed or design issues)

Additional ideas and inspiration for tasks can be found in the Exercise types chapter from "Teaching Tech Together" and in the Catalog of pedagogical patterns chapter from "Teaching and Learning with Jupyter".

  • A Walkthrough is a written guided description of the journey from a problem to a solution.
  • It aims to teach how to solve programming problems in a methodical and thoughtful manner using the model.
  • The conceptual roots of the walkthrough as a teaching method are the ideas of worked examples and literate programming .
  • It is designed to prompt self-explanation by the learners.
  • Jupyter Notebook serves as the medium, and it includes active learning tasks.
  • Walkthroughs - Open Education Resources
  • Worked and faded examples - MIT Open Learning
  • Skudder, B., & Luxton-Reilly, A. (2014, January). Worked examples in computer science . In Proceedings of the Sixteenth Australasian Computing Education Conference-Volume 148 (pp. 59-64). Australian Computer Society, Inc..
  • Lauren Margulieux - Research and Papers - Subgoal Labels and Worked Examples
  • Literate Programming website
  • Knuth, D. E. (1984). Literate programming . The Computer Journal, 27(2), 97-111.
  • Exercise Types - Teaching Tech Together
  • Catalog of Pedagogical Patterns - Teaching and Learning with Jupyter
  • The Carpentries Curriculum Development Handbook

Copyright © 2020 Shlomi Hod. All rights reserved.

results matching " "

No results matching " ".

  • Python Programming
  • C Programming
  • Numerical Methods
  • Dart Language
  • Computer Basics
  • Deep Learning
  • C Programming Examples
  • Python Programming Examples

Problem Solving Using Computer (Steps)

Computer based problem solving is a systematic process of designing, implementing and using programming tools during the problem solving stage. This method enables the computer system to be more intuitive with human logic than machine logic. Final outcome of this process is software tools which is dedicated to solve the problem under consideration. Software is just a collection of computer programs and programs are a set of instructions which guides computer’s hardware. These instructions need to be well specified for solving the problem. After its creation, the software should be error free and well documented. Software development is the process of creating such software, which satisfies end user’s requirements and needs.

The following six steps must be followed to solve a problem using computer.

  • Problem Analysis
  • Program Design - Algorithm, Flowchart and Pseudocode
  • Compilation and Execution
  • Debugging and Testing
  • Program Documentation

Adrian Prieto

Web Developer

Web Development

5 Steps to Solving Programming Problems

what are the steps in problem solving in programming

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

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

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

2. Solve the problem manually

Nothing can be automated that cannot be done manually!

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

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

3. Make your manual solution better

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

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

4. Write pseudo code

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

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

ie. square (n)

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

5. Replace pseudo-code with real code

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

Lets use our square example:

Then we optimize it:

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

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

  • How to solve problems – by John Sonmez
  • Pinterest 0
  • Recent Posts

' src=

  • Installing phpcs on a Mac ft. VSCode & WordPress, The Really Simple Guide - May 8, 2021
  • How To Set Up Your WordPress Development Environment with a Large Database ft. MAMP & Mac, The Really Simple Guide - April 24, 2020
  • Next.js ▲ + Typescript + Storybook The Really Simple Guide 2019 - November 25, 2019

You may also like

what are the steps in problem solving in programming

How I Built a Sinatra Web App In 10 steps

what are the steps in problem solving in programming

Installing Apache, PHP, and MySQL on Mac OS X

what are the steps in problem solving in programming

5 Steps to Building the Basics of a Job Board Rails App with Authentication and Authorization

thecleverprogrammer

How to Develop Problem Solving Skills in Programming?

Aman Kharwal

  • February 13, 2021
  • C++ , Machine Learning

Developing problem solving skills in programming is very important because the success of any task assigned to you depends on how accurately you define the problem to design and implement a solution. So in this article, I will tell you how to develop problem solving skills in programming.

Why do We Need to Have Problem Solving Skills?

In programming, problem solving means the process of understanding a problem to design a solution for the identified problem and then implementing the solution by writing a program using a programming language to tell the computer how to deal with the identified problem.

Also, Read – Python Projects with Source Code: Solved and Explained.

When we are assigned a task, the first step is to understand what problem we need to solve because when we write a program to design a solution, the computer gives us an output that is completely dependent on the input. So that the accuracy of the output given by our program depends entirely on the accuracy of the input provided by us.

So, to provide correct input and receive accurate output, it is very important to understand the problem and then design an algorithm to solve the problem. This is why we need to develop problem solving skills in programming.

So how do you develop problem solving skills in programming? Let’s understand by an example. Suppose you are driving and your car suddenly starts to make noise. So you might not know how to fix this kind of problem, but the first thing you will do is check where the noise is coming from and then take the car to the mechanic.

Then the mechanic will understand the problem with the car by analyzing the problem and understanding the source of the noise, then he will determine what to do and begin to make a plan on what he needs and how he will do it. In the end, he will start to implement the plan to fix the car.

So, from the example above, it is clear that to develop problem solving skills in programming, you need to go through a series of steps. Here are the steps to follow to resolve a problem:

what are the steps in problem solving in programming

  • Analyze the problem
  • Develop an algorithm

Now let’s go through all the steps mentioned above to understand how to develop problem solving skills in programming.

Analyze the Problem:

It is very important to understand the problem before designing a solution. If you don’t know what the problem is, you may end up writing a good program, but that won’t help solve the problem. So it is very important to read and analyze the problem statement to create a plan to solve the problem.

Thus, analyzing the problem will help determine what should be an input to the program that will give the correct output to resolve the problem.

Develop an Algorithm:

An algorithm is a set of instructions to follow to solve a problem. So after you understand the problem statement, it is very important to write a set of steps that you will take to solve this problem which is nothing but an algorithm.

You can think of an algorithm as the steps or procedure to complete a task. It’s good to create more than one algorithm to solve a problem so that you can pick the best one out of all the plans you have made to solve a problem.

So after selecting the best algorithm, you need to implement it using a programming language. When you have a set of instructions with you that you need to follow to solve a problem, trust me, it will help you with any complex problem.

The only thing to learn is that you need to master the fundamentals of the programming language you are using to solve the problem.

So to develop problem solving skills in programming you need to start by understanding the problem, then developing an algorithm and then start writing code by following the steps as per your algorithm. I hope you liked this article on how to develop problem solving skills in programming. Feel free to ask your valuable questions in the comments section below.

Aman Kharwal

Aman Kharwal

Data Strategist at Statso. My aim is to decode data science for the real world in the most simple words.

Recommended For You

How Much Python is Required for Data Science

How Much Python is Required for Data Science

  • June 7, 2023

Best Courses for Coding Interview Preparation

Best Courses for Coding Interview Preparation

  • October 28, 2022

How to Install MySQL on MacBook

Here’s How to Install MySQL on MacBook

  • September 1, 2022

Examples of the Applications of Python

Examples of the Applications of Python

  • June 17, 2022

Leave a Reply Cancel reply

Discover more from thecleverprogrammer.

Subscribe now to keep reading and get access to the full archive.

Type your email…

Continue reading

Problem Solving Through Programming in C

In this lesson, we are going to learn Problem Solving Through Programming in C. This is the first lesson while we start learning the C language.

Introduction to Problem Solving Through Programming in C

Regardless of the area of the study, computer science is all about solving problems with computers. The problem that we want to solve can come from any real-world problem or perhaps even from the abstract world. We need to have a standard systematic approach to problem solving through programming in c.

In this chapter, we will learn problem-solving and steps in problem-solving, basic tools for designing solution as an algorithm, flowchart , pseudo code etc.

The computer cannot solve the problem on its own, one has to provide step by step solutions of the problem to the computer. In fact, the task of problem-solving is not that of the computer.

Steps to Solve a Problem With the Computer

Step 1: understanding the problem:.

Here we try to understand the problem to be solved in totally. Before with the next stage or step, we should be absolutely sure about the objectives of the given problem.

Step 2: Analyzing the Problem:

Step 3: developing the solution:, step 4: coding and implementation:.

The last stage of problem-solving is the conversion of the detailed sequence of operations into a language that the computer can understand. Here, each step is converted to its equivalent instruction or instructions in the computer language that has been chosen for the implantation.

The problem solving is a skill and there are no universal approaches one can take to solving problems. Basically one must explore possible avenues to a solution one by one until she/he comes across the right path to a solution.

Problem Solving Steps

A problem-solving technique follows certain steps in finding the solution to a problem. Let us look into the steps one by one:

1. Problem Definition Phase:

2. getting started on a problem:.

There are many ways of solving a problem and there may be several solutions. So, it is difficult to recognize immediately which path could be more productive. Problem solving through programming in C.

3. Use of Specific Examples:

This approach of focusing on a particular problem can give us the foothold we need for making a start on the solution to the general problem.

4. Similarities Among Problems:

5. working backwards from the solution:.

In some cases, we can assume that we already have the solution to the problem and then try to work backwards to the starting point. Even a guess at the solution to the problem may be enough to give us a foothold to start on the problem.

General Problem Solving Strategies:

1. divide and conquer:.

The most widely known and used strategy, where the basic idea is to break down the original problem into two or more sub-problems, which is presumably easier or more efficient to solve.

2. Binary Doubling:

3. dynamic programming:, 4. general search, back tracking and branch-and-bound:.

All of these are variants of the basic dynamic programming strategy but are equally important.

Share This Story, Choose Your Platform!

Related posts, what is preprocessor in c, what is file handling in c, structures and unions in c.

Status.net

What is Problem Solving? (Steps, Techniques, Examples)

By Status.net Editorial Team on May 7, 2023 — 5 minutes to read

What Is Problem Solving?

Definition and importance.

Problem solving is the process of finding solutions to obstacles or challenges you encounter in your life or work. It is a crucial skill that allows you to tackle complex situations, adapt to changes, and overcome difficulties with ease. Mastering this ability will contribute to both your personal and professional growth, leading to more successful outcomes and better decision-making.

Problem-Solving Steps

The problem-solving process typically includes the following steps:

  • Identify the issue : Recognize the problem that needs to be solved.
  • Analyze the situation : Examine the issue in depth, gather all relevant information, and consider any limitations or constraints that may be present.
  • Generate potential solutions : Brainstorm a list of possible solutions to the issue, without immediately judging or evaluating them.
  • Evaluate options : Weigh the pros and cons of each potential solution, considering factors such as feasibility, effectiveness, and potential risks.
  • Select the best solution : Choose the option that best addresses the problem and aligns with your objectives.
  • Implement the solution : Put the selected solution into action and monitor the results to ensure it resolves the issue.
  • Review and learn : Reflect on the problem-solving process, identify any improvements or adjustments that can be made, and apply these learnings to future situations.

Defining the Problem

To start tackling a problem, first, identify and understand it. Analyzing the issue thoroughly helps to clarify its scope and nature. Ask questions to gather information and consider the problem from various angles. Some strategies to define the problem include:

  • Brainstorming with others
  • Asking the 5 Ws and 1 H (Who, What, When, Where, Why, and How)
  • Analyzing cause and effect
  • Creating a problem statement

Generating Solutions

Once the problem is clearly understood, brainstorm possible solutions. Think creatively and keep an open mind, as well as considering lessons from past experiences. Consider:

  • Creating a list of potential ideas to solve the problem
  • Grouping and categorizing similar solutions
  • Prioritizing potential solutions based on feasibility, cost, and resources required
  • Involving others to share diverse opinions and inputs

Evaluating and Selecting Solutions

Evaluate each potential solution, weighing its pros and cons. To facilitate decision-making, use techniques such as:

  • SWOT analysis (Strengths, Weaknesses, Opportunities, Threats)
  • Decision-making matrices
  • Pros and cons lists
  • Risk assessments

After evaluating, choose the most suitable solution based on effectiveness, cost, and time constraints.

Implementing and Monitoring the Solution

Implement the chosen solution and monitor its progress. Key actions include:

  • Communicating the solution to relevant parties
  • Setting timelines and milestones
  • Assigning tasks and responsibilities
  • Monitoring the solution and making adjustments as necessary
  • Evaluating the effectiveness of the solution after implementation

Utilize feedback from stakeholders and consider potential improvements. Remember that problem-solving is an ongoing process that can always be refined and enhanced.

Problem-Solving Techniques

During each step, you may find it helpful to utilize various problem-solving techniques, such as:

  • Brainstorming : A free-flowing, open-minded session where ideas are generated and listed without judgment, to encourage creativity and innovative thinking.
  • Root cause analysis : A method that explores the underlying causes of a problem to find the most effective solution rather than addressing superficial symptoms.
  • SWOT analysis : A tool used to evaluate the strengths, weaknesses, opportunities, and threats related to a problem or decision, providing a comprehensive view of the situation.
  • Mind mapping : A visual technique that uses diagrams to organize and connect ideas, helping to identify patterns, relationships, and possible solutions.

Brainstorming

When facing a problem, start by conducting a brainstorming session. Gather your team and encourage an open discussion where everyone contributes ideas, no matter how outlandish they may seem. This helps you:

  • Generate a diverse range of solutions
  • Encourage all team members to participate
  • Foster creative thinking

When brainstorming, remember to:

  • Reserve judgment until the session is over
  • Encourage wild ideas
  • Combine and improve upon ideas

Root Cause Analysis

For effective problem-solving, identifying the root cause of the issue at hand is crucial. Try these methods:

  • 5 Whys : Ask “why” five times to get to the underlying cause.
  • Fishbone Diagram : Create a diagram representing the problem and break it down into categories of potential causes.
  • Pareto Analysis : Determine the few most significant causes underlying the majority of problems.

SWOT Analysis

SWOT analysis helps you examine the Strengths, Weaknesses, Opportunities, and Threats related to your problem. To perform a SWOT analysis:

  • List your problem’s strengths, such as relevant resources or strong partnerships.
  • Identify its weaknesses, such as knowledge gaps or limited resources.
  • Explore opportunities, like trends or new technologies, that could help solve the problem.
  • Recognize potential threats, like competition or regulatory barriers.

SWOT analysis aids in understanding the internal and external factors affecting the problem, which can help guide your solution.

Mind Mapping

A mind map is a visual representation of your problem and potential solutions. It enables you to organize information in a structured and intuitive manner. To create a mind map:

  • Write the problem in the center of a blank page.
  • Draw branches from the central problem to related sub-problems or contributing factors.
  • Add more branches to represent potential solutions or further ideas.

Mind mapping allows you to visually see connections between ideas and promotes creativity in problem-solving.

Examples of Problem Solving in Various Contexts

In the business world, you might encounter problems related to finances, operations, or communication. Applying problem-solving skills in these situations could look like:

  • Identifying areas of improvement in your company’s financial performance and implementing cost-saving measures
  • Resolving internal conflicts among team members by listening and understanding different perspectives, then proposing and negotiating solutions
  • Streamlining a process for better productivity by removing redundancies, automating tasks, or re-allocating resources

In educational contexts, problem-solving can be seen in various aspects, such as:

  • Addressing a gap in students’ understanding by employing diverse teaching methods to cater to different learning styles
  • Developing a strategy for successful time management to balance academic responsibilities and extracurricular activities
  • Seeking resources and support to provide equal opportunities for learners with special needs or disabilities

Everyday life is full of challenges that require problem-solving skills. Some examples include:

  • Overcoming a personal obstacle, such as improving your fitness level, by establishing achievable goals, measuring progress, and adjusting your approach accordingly
  • Navigating a new environment or city by researching your surroundings, asking for directions, or using technology like GPS to guide you
  • Dealing with a sudden change, like a change in your work schedule, by assessing the situation, identifying potential impacts, and adapting your plans to accommodate the change.
  • How to Resolve Employee Conflict at Work [Steps, Tips, Examples]
  • How to Write Inspiring Core Values? 5 Steps with Examples
  • 30 Employee Feedback Examples (Positive & Negative)
  • School Guide
  • Class 8 Syllabus
  • Maths Notes Class 8
  • Science Notes Class 8
  • History Notes Class 8
  • Geography Notes Class 8
  • Civics Notes Class 8
  • NCERT Soln. Class 8 Maths
  • RD Sharma Soln. Class 8
  • Math Formulas Class 8

How to Use Algorithms to Solve Problems?

  • Wicked Problems and How to Solve Them?
  • How to implement Genetic Algorithm using PyTorch
  • Best Data Structures and Algorithms Books
  • How to Solve Maths Problems with Google Circle for Students
  • Tricks To Solve Age-Based Problems
  • 10 Best Math AI Solvers to Solve Math Problems Online
  • The Role of Algorithms in Computing
  • Most important type of Algorithms
  • How to Identify & Solve Binary Search Problems?
  • Quiz on Algorithms | DSA MCQs
  • Introduction to Beam Search Algorithm
  • Algorithms Quiz | Sudo Placement [1.8] | Question 5
  • Top 50 Problems on Recursion Algorithm asked in SDE Interviews
  • What are Logical Puzzles And How to Solve them?
  • What is Algorithm | Introduction to Algorithms
  • Top 10 Algorithms in Interview Questions
  • Top 20 Greedy Algorithms Interview Questions
  • Data Structures & Algorithms Guide for Developers
  • Top 50 Binary Search Tree Coding Problems for Interviews

An algorithm is a process or set of rules which must be followed to complete a particular task. This is basically the step-by-step procedure to complete any task. All the tasks are followed a particular algorithm, from making a cup of tea to make high scalable software. This is the way to divide a task into several parts. If we draw an algorithm to complete a task then the task will be easier to complete.

The algorithm is used for,

  • To develop a framework for instructing computers.
  • Introduced notation of basic functions to perform basic tasks.
  • For defining and describing a big problem in small parts, so that it is very easy to execute.

Characteristics of Algorithm

  • An algorithm should be defined clearly.
  • An algorithm should produce at least one output.
  • An algorithm should have zero or more inputs.
  • An algorithm should be executed and finished in finite number of steps.
  • An algorithm should be basic and easy to perform.
  • Each step started with a specific indentation like, “Step-1”,
  • 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.  

Step 6: Add some tea leaves to the water according to the requirement.

Step 7: Then again wait for some time until the water is getting colorful as tea.

Step 8: Then add some sugar according to taste.

Step 9: Again wait for some time until the sugar is melted.

Step 10: Turn off the gas burner and serve the tea in cups with biscuits.

Step 11: End

Here is an algorithm for making a cup of tea. This is the same for computer science problems.

There are some basics steps to make an algorithm:

  • Start – Start the algorithm
  • Input – Take the input for values in which the algorithm will execute.
  • Conditions – Perform some conditions on the inputs to get the desired output.
  • Output – Printing the outputs.
  • End – End the execution.

Let’s take some examples of algorithms for computer science problems.

Example 1. Swap two numbers with a third variable  

Step 1: Start Step 2: Take 2 numbers as input. Step 3: Declare another variable as “temp”. Step 4: Store the first variable to “temp”. Step 5: Store the second variable to the First variable. Step 6: Store the “temp” variable to the 2nd variable. Step 7: Print the First and second variables. Step 8: End

Example 2. Find the area of a rectangle

Step 1: Start Step 2: Take the Height and Width of the rectangle as input. Step 3: Declare a variable as “area” Step 4: Multiply Height and Width Step 5: Store the multiplication to “Area”, (its look like area = Height x Width) Step 6: Print “area”; Step 7: End

Example 3. Find the greatest between 3 numbers.

Step 1: Start Step 2: Take 3 numbers as input, say A, B, and C. Step 3: Check if(A>B and A>C) Step 4: Then A is greater Step 5: Print A Step 6 : Else Step 7: Check if(B>A and B>C) Step 8: Then B is greater Step 9: Print B Step 10: Else C is greater Step 11 : Print C Step 12: End

Advantages of Algorithm

  • An algorithm uses a definite procedure.
  • It is easy to understand because it is a step-by-step definition.
  • The algorithm is easy to debug if there is any error happens.
  • It is not dependent on any programming language
  • It is easier for a programmer to convert it into an actual program because the algorithm divides a problem into smaller parts.

Disadvantages of Algorithms

  • An algorithm is Time-consuming, there is specific time complexity for different algorithms.
  • Large tasks are difficult to solve in Algorithms because the time complexity may be higher, so programmers have to find a good efficient way to solve that task.
  • Looping and branching are difficult to define in algorithms.

Please Login to comment...

Similar reads.

  • School Learning
  • School Programming

Improve your Coding Skills with Practice

 alt=

What kind of Experience do you want to share?

IMAGES

  1. Six Steps to Solving a Programming Problem Infographic

    what are the steps in problem solving in programming

  2. programming steps to solve problems

    what are the steps in problem solving in programming

  3. 6 Ways to Improve Your Programming Problem Solving

    what are the steps in problem solving in programming

  4. Different Steps in Problem Solving in Programming

    what are the steps in problem solving in programming

  5. Problem Solving In Programming

    what are the steps in problem solving in programming

  6. programming problem solving process

    what are the steps in problem solving in programming

VIDEO

  1. Double in C

  2. Programming and Problem Solving

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

  4. Basic Steps in Problem Solving

  5. A Simple Technique to Solve Coding Problems

  6. Partial Sum شرح || Problem Solving

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. 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.

  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. 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.

  5. Problem Solving

    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. Pseudocode is writing out the logic for your program in natural language instead of ...

  6. How to think like a programmer

    Simplest means you know the answer (or are closer to that answer). After that, simplest means this sub-problem being solved doesn't depend on others being solved. Once you solved every sub-problem, connect the dots. Connecting all your "sub-solutions" will give you the solution to the original problem. Congratulations!

  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. 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.

  9. 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).

  10. How to Solve any Programming Problem

    Backup and state the problem. Sometimes, even when you collect all details, plan, and chunk the problem you cannot reach a solution. If you feel you are getting frustrated it is best to back up ...

  11. 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.

  12. CBSE Class 11

    The several steps of this cycle are as follows : Step by step solution for a problem (Software Life Cycle) 1. Problem Definition/Specification: A computer program is basically a machine language solution to a real-life problem. Because programs are generally made to solve the pragmatic problems of the outside world.

  13. 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 ...

  14. How to think like a programmer

    Problem-solving skills are almost unanimously the most important qualification that employers look for….more than programming languages proficiency, debugging, and system design.

  15. UNIT 1: How to Think Like an Engineer

    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.

  16. Walkthrough · GitBook

    A programming problem solving walkthrough is a written guided description of the journey from a problem to a solution. It aims to teach how to solve programming problems in a methodical and thoughtful manner using the model. In other words, the knowledge to be learned is focused on the "how", and not on the programming language per se.

  17. PDF Computer Programming Problem Solving Process

    Example problem: Step 1 - Identify the problem that must be solved. The first step is to identify the problem that needs to be solved. In this example, the largest number in the list must be found and displayed. Step 2 - Understand what the problem presents. The problem presents a list of numbers.

  18. Problem Solving Using Computer (Steps)

    The following six steps must be followed to solve a problem using computer. Problem Analysis. Program Design - Algorithm, Flowchart and Pseudocode. Coding. Compilation and Execution. Debugging and Testing. Program Documentation. Computer based problem solving is a systematic process of designing, implementing and using programming tools during ...

  19. 5 Steps to Solving Programming Problems

    Solving problems is a programmer's bread and butter, and everyone has their own method, I personally found 5 steps that most likely than not will help you, not only to solve problems but to do it faster and more efficiently. 1. Read the problem several times until you can explain it to someone else. Read, read, read!

  20. How to Develop Problem Solving Skills in Programming?

    Here are the steps to follow to resolve a problem: Process of Solving a programming problem. Analyze the problem. Develop an algorithm. Code. Now let's go through all the steps mentioned above to understand how to develop problem solving skills in programming. Analyze the Problem:

  21. Problem Solving Through Programming in C

    Note: Practice C Programs for problem solving through programming in C. Problem Solving Steps. Problem-solving is a creative process which defines systematization and mechanization. There are a number of steps that can be taken to raise the level of one's performance in problem-solving. A problem-solving technique follows certain steps in ...

  22. What is Problem Solving? (Steps, Techniques, Examples)

    The problem-solving process typically includes the following steps: Identify the issue: Recognize the problem that needs to be solved. Analyze the situation: Examine the issue in depth, gather all relevant information, and consider any limitations or constraints that may be present. Generate potential solutions: Brainstorm a list of possible ...

  23. 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.

  24. Boost Your Programming Problem-Solving Skills for the Future

    Collaboration is a cornerstone of successful problem-solving in programming. Engaging with other developers allows you to gain new insights and learn alternative approaches to problems.

  25. A 4 Step Approach to Problem-Solving

    The do-it-differently every time approach to problem-solving makes problem-solving difficult for individuals and teams. Without a standard approach like the ones we teach in our corporate program, you must think about how to solve the problem in addition to thinking about solving the problem. This also means you approach each problem ...