In 1945 Hungarian mathematician George Pólya described a famous method of problem-solving:
This may sound a bit abstract, so let’s translate this method into more concrete steps.
Write exact, atomic steps needed to solve the problem. They can be written on a piece of paper or as comments in the file containing the code.
This forces you to think about the code before you write it and helps you catch issues or misunderstandings before you dive into details (e.g. language syntax).
With well-defined steps, solving the problem should be much easier. If you struggle, go back to the previous steps to make sure you understand the problem and know exactly what to do. You can also try alternative approaches, such as solving a similar problem or solving a simplified version of the current problem by temporarily excluding the most difficult part.
This strategy is inspired by Colt Steele.
Deliberate (Kata) practice is a great supplement to the above strategy. It requires attention and rework, and leads to new knowledge and skills that can later be developed into more complex ones.
In practice:
Repeat these steps over a period of days, weeks, or months. Bit by bit you will understand the problem better and the challenge will feel familiar. Keep going until solving it is as easy as adding 97 and 3.