If you are having trouble deciding how to code something, write out the steps in plain English first, as if you are writing a recipe. When you are satisfied with your algorithm, convert the “pseudocode” into real code.