At this point in the book, you will often run into exercises and coding problems for which you are unsure how to solve them. I gave an example of such a problem above (finding of ten numbers the largest, the smallest, and the number divisible by 3), and the solution I came to. Such a solution approach is called an “algorithm.” But how do you design such algorithms?
I often see students typing code without really knowing what they are doing. They are trying to solve a problem but do not know how, so they start typing. You may realize that this is not a good approach to creating solutions (even though experimenting a bit might help).
What you have to do in such a situation is sit back, leave the keyboard alone, and think “How would I solve this problem as a human?” Try to write down what you would do if you would do it by hand. It does not matter if what you would do is a very boring task that you would never want to do by hand – you have a computer to do the boring things for you.
Once you have figured out what you would do, then try to think about how you would translate that to code. Because basically, that is what you need to tell the computer: the steps that you as a human would take to get to a solution. If you really cannot think of any way that you as a human would use to solve a problem, then you sure as hell won’t be able to tell the computer how to do it for you.