Image by PublicDomainPictures from Pixabay

Should you avoid look at solutions when solving problem? The answer seems simple – either you look or you don’t. But it is not. For me, the answer, when I learned to code, was not to look at the answer. But after 15+ years of experience, the answer is to look at the solution. But nobody tells that. Everybody asks you to think on your own to develop the solution. But reading solution within a structured process helps you enhance your learning.

Problem

It is a dilemma new programmers face. Part of the reason is how we learn from an early age. We were told to not look for the solution and try to solve the problem on our own. But we forgot, somebody used to always show us a solution which we would benchmark to find the solution.

This leads to the feeling of cheating and corresponding guilt when we look at the solution after spending hours on it and not being able to find it. As new programmers, this feeling makes us feel we are not making progress. This may lead us to feel programming is not for us and we feel lost with our decision.

The next time we sit to code if we ever sit, we remember this unpleasant memory and we procrastinate by looking at other million things that the internet can keep us occupied with.

Solution

But what does research on learning says? When we work on a problem, our brain is establishing new patterns to enable it to solve the problem. So we are already making progress when we are trying to solve the problem.

There are two modes of learning that the brain uses.

Focussed learning happens when you are putting your raw brain power to solve the problem going on for hours.

Source: Chegg.com

Diffused learning happens when you are not trying to learn. i.e. you are out on a walk, chatting to people, spending time with family, or listening to music. The brain would still work in the background to assimilate the earlier learning into past known patterns and create new neurological patterns so that it can solve them the next time around.

Source: Chegg.com

A good sleep speeds up diffused learning. I know I have woken up a few times in the morning with a solution to the problem that I had before going to sleep. Your brain is amazing. You can give the problem to your brain and go to sleep. You get to relax and it does the heavy lifting in the background to give you a solution.

How do you use these modes of learning to code?

The idea is to use both strategies depending on where you are in your learning journey. Switch both modes in your journey as you learn, relearn and unlearn unfamiliar concepts whenever you code.

Source: Chegg.com

Remember how you learnt alphabets

Imitate when you being learning. When you are beginning learning, your brain does not have the learning muscle to know how to code. Consider you are learning alphabets as a kid. You read and write the alphabet many times to learn it.

It is the same with programming. You need to look at solutions to understand how to solve the problem first. Try to make it work on your laptop. Avoid copy-pasting and write it from the solution. This will get you the feel of the language.

The next step is forming words from the alphabets. You are still not there yet. But you find you need to search for solutions sometimes. At this stage, exercising your brain to find a solution is important. The racking of the brain creates neural pathways, but your brain needs help.

With code, you learn to build loops, if-conditions. You cannot solve complex problems, but you can solve many problems with some help at this stage.

Pomodoro Technique

The Pomodoro Technique is a time management system that encourages people to work with the time they have—rather than against it. Using this method, you break your workday into 25-minute chunks separated by five-minute breaks. These intervals are referred to as pomodoros. After about four pomodoros, you take a longer break of about 15 to 20 minutes.

The Muse

The Pomodoro technique can help you out here. For me, if I am in the flow mode, I don’t take a break unless I hit a roadblock. That would happen around 90-120 minute mark. So I start the timer for 25 minutes to get into the flow but once there, I go on for a 90-120 minutes or until I hit a roadblockand then take a break.

As I have hit a problem and have spent a good amount of brain power, I let go at this stage. I would play with my kids, talk with others and just walk around until I feel I am ready to dive back in. I do not put a time to get back because I would just know when I can. If I take a longer than usual break, I would hurry back, put my headphones on and get back to the problem.

Bring it all together

How do you make use of all this information? These steps are for a programmer learning to code by solving medium to complex problems or doing LeetCode.

Start the Pomodoro timer

Download an app for Pomodoro and start the timer for 25 minutes. If you get in the flow, do not stop. Go on solving the problem until you feel you hit a roadblock. Doing it first few times, you may feel uncertain about the process and will have doubts if you have hit a roadblock. It is ok. The more you do it, the better you will get at it. But do not go beyond 90-120 minutes. You can also stop after 90 minutes if you feel you have made some progress and the next step will require significant problem solving.

If you will feel tired after 25 minutes or at any later point in time, take a break.

Break

The break can be a 20-minute break – wherein you talk to someone, go for a walk, and drink water. Celebrate the 2 hours you spent solving the problem. Pat yourself. But don’t punish yourself for not solving it.

I suggested 20 minutes, but it should be as long as you feel you are ready to get back in.

Tip: Avoid scrolling on your phone or any kind of screen-time. It is important to get off the chair and do something off-screen. Scrolling on the phone just numbs the brain, and it becomes harder to get back.

Second Session

Come back for one session of 25 minutes. Rack your brain for another solution. The reason is the diffused mode of learning would have kicked in during your break. There might be a solution around the corner.

If after 25 minutes, you still did not find a solution, take a breath and step back. Acknowledge that you have spent enough time on it and your brain has done a good job finding all the options that did not work. Go through the solution. Implement and understand the solution and compare find out what you missed.

Close Session

Write wins and takeaways from the session. Pat yourself for the work done and smile. Take rest and don’t work on solving any more problems for the day if possible.

Why does this work?

What this process does is it gives your brain to form pathways when you were trying different approaches.

The break allows your mind to drift, which creates unexpected links in your brain and you might get to a solution after the break with the help of diffused learning.

Finally, the last part will help your brain find the missing link. It will make the new connection and patterns within your brain.

Avoiding doing any more problem solving is also important as it kicks in “spaced repetition”. It allows the brain to solidify the learning and be ready for the next session.

Each of the above cycles builds your problem-solving muscle little by little. The result will not be apparent in a week, but in a month or two months’ time, you will find the difference.

What next?

The next step is to build projects. This will make you find solutions to problems that you face on the fly. It will reinforce your learning and create new pathways. Here you use the combination of working from memory and looking up solutions online.

Let me know what you think about this. Thanks for reading!