These generalized strategies will improve your creative problem-solving abilities. I teach them to my students and rehearse them in different contexts. It’s often difficult to learn these working alone.
Try these strategies the next time you tackle a difficult problem.
- Work out an example by hand.
- Solve a simpler problem first.
- Keep this motto in mind: Any attempt is progress.
- Write down your questions.
Here’s an explanation of these:
Work out an example by hand
Take an example problem (starting with the sample input they give) and work it through to the answer by hand. As you do, pay attention to what techniques you’re using and think about how they could be expressed in code. Then try to invent your own example input, attempting to make some variation on the problem that’s not quite what you would expect. This is a good first strategy, even before you code anything up.
Solve a simpler problem first
This is a powerful strategy. In this strategy, you figure out how to solve some single piece of the problem before tackling the whole thing.
I work with my students a lot on understanding how to apply this, because it’s easy to misunderstand.
An analogy: writing an algorithm to shovel a sidewalk of snow
Suppose you’re writing an algorithm to shovel snow from a stretch of sidewalk. How can we apply Solve a simpler problem first?
The first idea you might have is to shovel one shovelfull of snow. That’s the one piece of the problem, and you then extend that to the whole sidewalk later.
But another way of looking at it is this: Shoveling involves things like picking up the shovel, moving the shovel, having the ability to carry the weight of snow, and so forth. When I say solve a simpler problem first, I mean something like that. Figure out how to pick up the shovel. Then figure out how to move the shovel. And so on.
Consider how the first idea, figuring out how to shovel one shovelfull of snow, really contains the entire problem. So, it’s not a simpler piece.
In other words, don’t solve the same problem with less data, but solve simpler problems with less stuff going on. I work with my students consistently on internalize this strategy.
Keep this motto in mind: Any attempt is progress
Working on USACO problems is a difficult experience, with progress coming in fits and starts. It’s easy to get discouraged when you get stuck, or worse, have to backtrack and throw code away. But I believe that you can learn from your mistakes. Every attempt teaches you something and gets you closer to the goal. This is why I believe so much in encouraging my students. I’m helping them see that all their attempts mean progress.
Note: This motto applies to study and preparation for the test beforehand when you have all the time you need to study and solve a problem. During the competition, with its time limits, it does become more important to save time by knowing when a path is fruitless. This is a skill you can develop only with experience. Applying this motto to your problem study can give you that necessary experience. As Will Rogers said, “Avoiding mistakes comes from experience. Experience comes from making mistakes.”
Write down your questions
A powerful technique for dealing with confusion is to take a step back and stop trying to make direct progress. Instead, clarify your questions. Try writing down the various questions you may have about the problem even if you don’t have answers right away. Then, as you work on the problem, you may gradually find answers. In essence, you’re priming your mind to recognize answers to your questions when you stumble on them.
Additional strategies and techniques
Read about additional strategies and techniques here: