PDF

What is a sanity check?

A sanity check is a quick, simple test you do to see if an answer or idea looks reasonable. It doesn’t prove something is totally correct, but it helps you notice obvious mistakes fast.

Why use a sanity check?

  1. Catch silly errors before they cause problems.
  2. Save time by spotting something wrong early.
  3. Build confidence that your work is probably okay.

How to do a sanity check — step by step

  1. Look at your result. Ask: does this seem possible or normal?
  2. Compare with something simple you know (a rough estimate or a known fact).
  3. Try an easy check: a small example, a reverse step, or a quick mental calculation.
  4. If it looks reasonable, great. If not, go back and find the mistake.

Examples a 12-year-old will recognize

  • Math homework: You got 1,234 × 56 = 69,104. A sanity check: 1,234 is about 1,200 and 56 is about 50, so 1,200 × 50 = 60,000. Your answer 69,104 is near 60,000, so it looks reasonable. If your answer were 6,910, that would fail the sanity check.
  • Recipe: A cookie recipe says 5 cups of salt. Sanity check: most recipes use a tiny amount of salt, not 5 cups. That sounds wrong — probably a mistake (maybe they meant 5 teaspoons).
  • Video game score or speed: If your character’s speed suddenly jumps from 10 to 10,000 after a small change, do a sanity check — that huge jump is probably a bug.
  • Coding: If a program says there are 100,000 users but you know the site only has about 500, a quick sanity check shows a problem. You might print intermediate values or test with a small input to find the bug.

Quick checklist to use every time

  1. Does the result match a rough guess or known range?
  2. Can I test it with a very small example?
  3. Does it match the units (hours, meters, dollars)?
  4. Does reversing the step give the original value (when possible)?

Short practice — try these

  1. You add numbers and get 10,001 as the sum of "12 + 7 + 5". Sanity check: those numbers add to about 24, not 10,001. Something is wrong.
  2. You bake 24 cookies. A friend says she baked 2,400 cookies in one small oven. Sanity check: ask how many batches and what oven size — 2,400 is probably not realistic.
  3. Test a tiny case in code: if your program should count items in a list, try a list with 2 items. Does it return 2?

One last tip

Sanity checks are fast and useful, but they aren’t perfect. If a sanity check passes, you still might need a more careful check later. Think of a sanity check as a quick first defense against obvious mistakes.

If you want, tell me an example (homework problem, recipe, game score, or a short piece of code) and I’ll show how to do a sanity check on it.


Ask a followup question

Loading...