DEV Community

Cover image for 5 Proven ways to Solve any Coding Problems Like an Expert in 2022
Sojin Samuel
Sojin Samuel

Posted on • Updated on

5 Proven ways to Solve any Coding Problems Like an Expert in 2022

According to Indeed, an American job-search website, problem-solving skills are the fourth most important skill required as a programmer.

Code is frequently written to solve a problem; by problems, I don't mean errors in your code; rather, I mean real-world problems that require solutions.
You should have encountered problems in your code at some point; how you solve these problems not only demonstrates your level of experience as a developer, but also speaks volumes about how much of the problem you understand.

In this article, I'll walk you through a four-step framework for solving problems like a pro, as well as solve a real-world problem to solidify our understanding.

1. Recognize the issue

Most difficult problems we face are only difficult because we do not understand them; understanding a problem simply means you understand what is wrong and what it takes to correct it; one way to tell if you understand a problem is to try explaining it to yourself in simple terms.

If you can't explain the problem in simple terms, you don't understand it. To understand a problem, do the following:

  • Read the question.
  • Make note of your findings.
  • Present critical questions

This will become clear as we solve the simple problem below.

Use JavaScript to execute
If you are over the age of 18, log a string like this to the console: "I am eligible to vote." Otherwise, log a string like "I am not eligible to vote because I am "2 years" younger than the voting age." (the 2 represents 18 minus our current age)

The following are our observations:

  • If represents a conditional statement.
  • A logical operator is represented by greater than or equal to.
  • We must first access the developer console.
  • What else does it or otherwise mean?; Because there is an if statement, otherwise should be an else statement.
  • We must replace the "2" years with 18 minus our current age.

Read: Here it is The 5 Proven Tips For Writing Cleaner and Efficient Code

2. Separate and conquer

This is a common army strategy; how can you defeat a large enemy? Divide them into small portions using distraction or calculated risks, and then attack them accordingly. The same is true in programming, except that we are not distracting anyone or taking any calculated or uncalculated risks.

Don't try to solve one big problem at a time; instead, divide it into subproblems. You'll save time and stress, and the problem will be much easier to solve.

  • We define our current age in order to continue solving our problem.
  • The resulting age is determined by us.
  • We put the conditional statements into action and log the strings to the console.
  • If our age is insufficient(18), we perform the alternative operation.

3. Do Some Research

Whether you admit it or not, you don't know everything, and when you find yourself constantly hitting a brick wall, it's time to take a break and do some research. There is no problem that you will face that someone else has not encountered or solved.

It may interest you to know that some of the programmers you admire are also excellent researchers. The importance of research as part of your job as a programmer cannot be overstated.

One thing to keep in mind when researching is that you don't always find the solution to a problem all at once. Break the problem down into sub-problems and then conduct your research.What I mean is that if we wanted to conduct research on the problem presented in this article, it would look like this:

  • In javascript, how do you define a variable?
  • In javascript, how do you write conditional statements?
  • String logging in the developer console

4. Make Pseudocode

Pseudocode is code that is written for humans to understand; there are no rules when writing it; it is similar to writing in your own programming language. Writing pseudocode aims to make the code easy to understand, especially if someone else is going through it.

Writing pseudocode may not be necessary when solving small problems like the one in this article, but when solving larger problems, writing pseudocode can help simplify the problem significantly.

This is the pseudocode for the problem we're working on.

make pseudocode

5. Problem Solving

Because we all have different approaches to solving a problem, my answer may differ from that of another.

problem solving

Wrap up

Problem-solving is a broad topic, and I have only attempted to capture what makes a better problem solver in this article; you will not become a professional by simply solving one problem, NO! It takes consistent practise, and solving a large number of problems will help you become a better problem solver.

Leetcode is a good place to start practising coding problems right away; there are over 2300 questions to practise, and you can also participate in contests to challenge yourself and earn rewards. By the way, they did not sponsor this article; I simply enjoy the platform.

So this is where I stop typing, I am a Noob Full Stack engineer(looking for job) andΒ I would also like to connect with more techies on Twitter.

Did you like my article, I bet you have felt love with it.

Now can you buy me a coffee,and Follow me on on Twitter for my latest article updates

Read More

Top comments (3)

Collapse
 
mjcoder profile image
Mohammad Javed

Good article, some really good points made. πŸ‘

Collapse
 
sojinsamuel profile image
Sojin Samuel

Thanks sir

Collapse
 
tarasbudzyn profile image
taras-budzyn

The final code is wrong.
Also there are no solution for problem from 1 point of article..