---Understand the problem--- To gain clarity and understanding of the problem, write it down on paper, reword it in plain English until it makes sense to you, and draw diagrams if that helps. When you can explain the problem to someone else in plain English, you understand it. ---Plan--- Now that you know what you’re aiming to solve, don’t jump into coding just yet. It’s time to plan out how you’re going to solve it first. Some of the questions you should answer at this stage of the process: Does your program have a user interface? What will it look like? What functionality will the interface have? Sketch this out on paper. What inputs will your program have? Will the user enter data or will you get input from somewhere else? What’s the desired output? Given your inputs, what are the steps necessary to return the desired output? ---Pseudocode--- Pseudocode is writing out the logic for your program in natural language instead of code. It helps you slow down and think through the steps your program will have to go through to solve the problem. Here’s an example of what the pseudocode for a program that prints all numbers up to an inputted number might look like: When the user inputs a number Initialize a counter variable and set its value to zero While counter is smaller than user inputted number increment the counter by one Print the value of the counter variable ---Divide and conquer--- From your planning, you should have identified some subproblems of the big problem you’re solving. Each of the steps in the algorithm we wrote out in the last section are subproblems. Pick the smallest or simplest one and start there with coding.
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter