Problem Solving in Programming
When I first started programming last year in 2020 I was so focused on what languages to learn and what applications could look like. While technologies and user experiences are critical to applications being developed, I found out that there is a bigger picture that is hidden behind shinier toys. What most developers know that beginners don’t know is that one of the most important pieces of this pie is problem solving.
There is a reason why many companies do some sort of coding challenge during the interview. companies need many problems solved quickly and more importantly efficiently. Data structures and algorithms have become a staple of every programmers learning for this reason.
I have been working on a personal project and I have run into multiple blockers. When I first started developing I would get blocked by superficial problems that were language or framework specific. Now that I have a stronger grip on my tech stack and building more complicated projects I am running different issues. Now I am running into programmatic thinking blockers, working with complex nested data sets, and algorithms to make sure my functions are running efficiently in terms of time and space.
Thankfully there are proven ways to think like a programmer and even help train yourself to become a better critical thinker. First in terms of basic programming problem solving you want to follow some of these steps:
- Read the problem — This seems obvious but so many people can get stuck here. You want to read and comprehend. Read it twice and read it out loud if you have to. Even talking a problem out loud to yourself or “rubber ducking” can knock the spiderwebs off and get you closer to a solution.
- Understanding input and output — This is also helpful in coding challenges. Knowing what you need to give your code and what the end goal is for the output is can actually get you out of the dark. Knowing your solution will take in some sort of data and will output some kind of primitave is a massive piece of the map.
- Pseudo-code — It can be helpful when you are stuck programming to turn it into English. While you are talking out loud stop coding and start jotting down where you are and where you need to get to in the process.
- Test — Once you have a solution you want to test multiple cases. Its important to test because assuming you found an answer or even finding an answer that works on the first test you do can be dangerous. There have been many times when I was practicing coding challengers on codewars where my solution passed multiple tests but missed out on a few.
- Optimize for time and space — Optimizing is the hardest step to take in the problem solving process. It takes a lot of studying and practice unlike most of the steps on the list. If you need direction you should be studying Big O Notation, data structures, and algorithms.
To improve your problem solving as a programmer you must also improve your general critical thinking skills. Here are some tips:
- Meet with a mentor — Having a person who you can fall back on to get you unstuck is helpful. You will be more willing to try things you otherwise would be intimidated by. Also hearing a solution to a problem you have been immersed in will help you remember and improve.
- Participate in teams — Talking out a problem alone can sometimes be too vague to help. Bouncing ideas off each other in a team can create new ideas.
- Ask for leadership roles — Leadership roles can put you in a situation under pressure where you will be forced to improve and care about finding a solution personally more than finding a solution to something you are less involved in. It takes pressure to make a diamond.
Some other tips to improve problem solving
- Diversify your thinking process.
- Explain it like you are explaining it you a child.
- Work Backwards.
- Expose yourself to new content and new creators.
- Experiment with brain teasers and ethical dilemmas.
- Surrounding Yourself With Critical Thinkers.
Below is a resource for some more fun exercises to practice!