Programming Rules of Thumb
Learn program patterns of general utility and use a relevant pattern (if you know one) for the problem at hand.
Seek inspiration by systematically working test data by hand. Be introspective; ask yourself: “What am I doing?”
Declare variables for each piece of information you maintain when working the problem by hand. Write comments that precisely describe the contents of each variable.
Remember the problem’s boundary conditions.
Validate your program by tracing it on simple test data.