How to solve a Problem - according to George Polya
2 min read
Steps to solve a problem
Understand the problem
What are the unknowns, knowns?
Is the problem solvable?
What are the stakeholder requirements
What are expected output and inputs
What are the intended side effects
Devise a plan
Implement the plan
Write the code
Reflect/Revise
Refactor
Think about the decisions made
Devising a plan
Draw a figure
Be systematic
Consider if the problem is similar to another problem previously solved
The problem may be an extension of an existing solved problem
Or the problem may be reformulated into a known form with a little bit of work
Induction - Generalize the problem from specific cases
Decomposing/Recomposing
Break down the problem into parts (the parts may or may not look similar)
Solve those part problems
Join back them together
Solve the easier version of the problem (auxiliary problem)
If the original problem is too hard, then solving its easier version is a good idea
By solving the easier problem, you learn a few things which may be able to help you solve the original (hard) problem
Define things
Like function names, variables, etc
By naming various parts of the problem, our brain can assume that the part has been solved even though the implementation of that particular part (function) remains
Walking backwards
Assume that you have solved 99% of the problem, then what would be required to go from 99% to 100%
Once this is done, we can try to figure out the step required from 98% to 99%