Chenna Malleswara Rao
Chenna Malleswara Rao's Blog

Chenna Malleswara Rao's Blog

Problem Solving.

Problem Solving.

Chenna Malleswara Rao's photo
Chenna Malleswara Rao
·Nov 24, 2022·

6 min read

Table of contents

  • 1.Introduction
  • 2.Understanding the Problem
  • 3.Plan
  • 4.PseudoCode
  • 5.Divide and Conquer
  • 6.Stuck?
  • 7.Practice
  • 8.Conclusion

1.Introduction

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

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

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 serve 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 blog we will walk through a few techniques that can be used to help with the problem solving process.

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

Know exactly what is being asked. Most problems are hard because you don’t understand them.

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?

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.

3.Plan

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.

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 these questions:

  • 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?

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

4.PseudoCode

Pseudocode is writing out the logic for your program in natural language instead of code. It helps you to 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 simple program that prints all numbers up to an inputted number might look like:

1. When the user inputs a number
2. Initialize a counter variable and set its value to zero
3. While counter is smaller than user inputted number increment the counter by one
4. Print the value of the counter variable

This is a very simple program to demonstrate how pseudocode looks.

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

6.Stuck?

By now, you’re probably sitting there thinking “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. This happens to everyone!

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

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

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

  • Reassess: Take a step back. Look at the problem from another perspective. Is there anything that can be abstracted to a more general approach?

Note: Another way of reassessing is start at the beginning. Delete everything and begin again with fresh eyes. I’m serious. You’ll be dumbfounded at how effective this is(this doesn’t Work every time though).

  • Research: Google it.Google is your best friend. 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).

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

7.Practice

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 the patterns of the problem.

How to practice? There are plenty of options out there!

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

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.

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

You need not spend hours of time on video games to improve your problem solving skills. You can integrate it with programming and start solving small challenges everyday

Remember. Consistency is the key!

8.Conclusion

That’s all folks!

Now, you know better what it means to “think about problem solving.”

You also know that problem-solving is an incredible skill to cultivate.

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

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

Now, go solve some problems!

And best of luck!!!

 
Share this