I tried and failed, again tried and failed. I became exhausted and started learning some basic concepts of programming.
In this article I am going to share
5 steps to solve any problem. So lets start.
Before start writing the code you need to understand the problem. Understanding the exact problem can solve your problem more than 30%. You can ask some questions before start writing the code:
- Can I restate the problem in my own words?
- What will be the inputs in the problem?
- What would be the outputs should come from the solution?
- Would input determine the output?
- How should I label the important pieces of data that are part of the problem?
After understanding the problem you need to explore the possibilities like:
- What if there is no input or invalid input?
- Is any limitations to the output? Try to find the more options to better understand the problem.
This is a most important method to solve any problem. You can break down the code into small steps to solve it. Write down the comments in steps, this will help you to be in track of solving the problem without distracting. Suppose, there is time limitation for solving any specific problem, and you are unable to solve it completely, your comments can help to get the good marks in that. Examiner would be able to understand your approach and right approach is the way to solve any problem.
After writing the steps, start solving the problem. Try to solve simple steps first and then solve the complex one.
After solving the complete problem, look back to your code and try to refactor it. Make it concise and readable. Try to test it at least one time before submitting.
I hope this will help you to get out of any problem easily. :)