Skip to content

Problem Solving Cheat Sheet

Structured approaches to breaking down hard problems.

George Polya’s four-phase framework from How to Solve It (1945).

  • What is the unknown? What are the data? What is the condition?
  • Can you restate the problem in your own words?
  • Draw a diagram. Introduce notation.
  • Separate the parts of the condition.

Test: Can you explain the problem to someone else?

  • Have you seen this problem before? Or a similar one?
  • Do you know a related problem with a known solution?
  • Can you solve a simpler version first?
  • Can you solve part of the problem?

Test: Can you articulate your approach before starting?

  • Carry out your plan step by step.
  • Check each step as you go.
  • Can you prove each step is correct?

Test: At each step, can you explain why it’s right?

  • Can you check the result?
  • Can you derive the result differently?
  • Can you use the result or method for another problem?
  • What did you learn?

Test: Would you solve it the same way next time?

General-purpose framework. Works for any problem. Especially useful when you’re stuck at the start and don’t know how to begin.

Break the problem into smaller, independent subproblems.

Original problem
├── Subproblem A → Solve → Solution A
├── Subproblem B → Solve → Solution B
└── Subproblem C → Solve → Solution C
Combine solutions
  • Subproblems should be independent (or nearly so)
  • Solutions should be combinable
  • Subproblems should be easier than the original
DomainBreak Into
SortingSort halves, merge results
ParsingLex, parse, validate, transform
Large tasksIdentify phases, complete one at a time
DebuggingIsolate components, test independently
LearningBreak skill into subskills, master each
  • Problem is too large to hold in your head
  • Clear boundaries exist between parts
  • You can solve subproblems independently
  • You can parallelize work

Watch for hidden dependencies between subproblems. If solving A changes the requirements for B, you don’t have independent subproblems.

Start from the goal and trace back to the start.

Goal state
↑ What step produces this?
Intermediate state
↑ What step produces this?
...
Start state
DomainApplication
Math proofsAssume conclusion, find what implies it
Test-driven devWrite the test first, then the code
DebuggingStart from error, trace back to cause
PlanningSet deadline, work backward to identify milestones
API designWrite the ideal call site, then implement
  • Goal is clearer than the path
  • Many possible starting points but one destination
  • Forward progress feels aimless
  • You need to set milestones or deadlines

Don’t confuse “what would give me the answer” with “what’s actually true.” Working backwards generates candidates; verify forward.

Find a similar problem you’ve already solved.

  1. Identify — What are the structural elements of this problem?
  2. Search — What similar problems have I seen?
  3. Map — Which elements correspond?
  4. Transfer — Apply the old solution to the new context
  5. Verify — Does the analogy actually hold?
New ProblemSimilar ProblemWhat Transfers
Rate limiting API callsTraffic light intersectionQueue theory, throttling
User permissionsPhysical key systemsHierarchies, inheritance
Database transactionsBank transfersACID properties
Load balancingCheckout lanes at a storeQueue distribution
  • Problem feels familiar but context is different
  • You have deep experience in adjacent domains
  • Standard solutions exist for similar problems
  • You want to leverage existing patterns

Surface similarity can mislead. The checkout lane analogy breaks down when requests have vastly different processing times. Verify that the structural similarity holds where it matters.

Remove constraints to find a solution to an easier problem, then add constraints back.

  1. List all constraints on the problem
  2. Remove one or more constraints
  3. Solve the relaxed problem
  4. Analyze how the solution violates removed constraints
  5. Modify the solution to satisfy all constraints
Original: Sort 1TB of data in 8GB RAM
Constraints:
- Must fit in 8GB RAM
- Must handle 1TB data
- Must produce sorted output
Relax "fit in RAM":
- If unlimited RAM → simple in-memory sort
Reintroduce constraint:
- External merge sort: sort chunks that fit, merge results
  • Too many constraints to consider simultaneously
  • You don’t know where to start
  • You want to understand which constraints make the problem hard
  • Looking for a baseline solution to improve

Some constraints are load-bearing. Relaxing “must not corrupt data” to make progress leads to solutions you can’t actually use.

Explain the problem out loud to externalize your thinking.

  • Forces you to articulate assumptions
  • Slows down thinking to speaking pace
  • Reveals gaps in understanding
  • Activates different cognitive processes than silent thought
  1. State what the code (or solution) should do
  2. Walk through step by step, explaining each part
  3. When you say “and then obviously…” — stop and verify
  4. The bug hides where explanation doesn’t match reality
AudienceBest For
Rubber duckLow-stakes, immediate
ColleagueFresh perspective, catches jargon
Written documentThorough analysis, future reference
Voice memoCaptures stream of consciousness
  • You’ve been staring at the same code for too long
  • The solution “should work” but doesn’t
  • You can’t articulate what’s failing
  • You’re about to ask someone for help (explain it first)

See also: Debugging for the full scientific method.

SituationTry
Don’t know where to startPolya’s method
Problem too bigDivide and conquer
Goal clearer than pathWorking backwards
Feels familiarAnalogical reasoning
Too many constraintsConstraint relaxation
”It should work but doesn’t”Rubber duck
Bug in codeSee Debugging

Techniques compose well:

  1. Use Polya’s method to understand the problem
  2. Use divide and conquer to break it into subproblems
  3. For each subproblem, try analogical reasoning first
  4. If stuck, relax constraints to find a starting point
  5. Use rubber duck when implementation doesn’t match expectation
  6. Work backwards from failing test to find the cause
TrapDescriptionAntidote
Premature optimizationSolving for performance before correctnessMake it work, make it right, make it fast
X-Y problemAsking about your solution, not your problemState the original goal
Tunnel visionCommitting to first approach that comes to mindGenerate three options before choosing
Analysis paralysisOverthinking instead of experimentingTime-box analysis, then try something
Complexity biasAssuming hard problems need complex solutionsTry the dumbest thing first

“If you can’t solve a problem, there is an easier problem you can solve: find it.” — George Polya

“The art of debugging is figuring out what you really told your program to do rather than what you thought you told it to do.” — Andrew Singer

“Weeks of coding can save you hours of planning.” — Unknown

“Make it work, make it right, make it fast.” — Kent Beck