Puzzles

Reasoning puzzles of the kind interviews ask, each with a worked solution that explains how to get there rather than only what the answer is.

A puzzle in an interview is rarely about the answer. What is being watched is how you start on something you have not seen before: whether you ask what the constraints are, whether you try a smaller version first, and whether you say what you are thinking. Silence followed by a correct answer scores worse than thinking aloud and getting most of the way.

So every puzzle here shows its working, and says which technique it is really about. That last part is the one worth keeping — parity, counting outcomes, balancing a worst case, finding an invariant. The answers you can look up; the techniques are what let you solve the one you were actually asked.

Start with these ten

Between them they cover every technique the rest reuse. Worked through in order, the later ones stop feeling like tricks.

  1. Three Bulbs and Three Switches Finding a second channel of information
  2. The Burning Ropes Changing the rate instead of reading the length
  3. Eight Balls, One Heavier Three outcomes from one weighing
  4. The Bridge and the Torch Making the expensive steps overlap
  5. Twenty-Five Horses Eliminating by transitivity
  6. A Hundred Doors, A Hundred Passes Counting divisors, and when the count is odd
  7. Ten Jars, One of Them Light Encoding identity in quantity
  8. Two Eggs and a Hundred Floors Balancing the worst case
  9. One Poisoned Bottle in a Thousand Reading an answer in binary
  10. A Hundred Prisoners and Their Hats Broadcasting one bit of parity

Logical puzzles

No arithmetic worth the name. What these test is whether you can find the piece of information nobody mentioned - a warm bulb, the parity of a count, a question whose answer is the same whoever you ask.

Puzzle What it tests Difficulty
Three Bulbs and Three Switches Three switches outside a room, three bulbs inside, and one trip in. Finding a second channel of information Easy
The Burning Ropes Two ropes that each burn for an hour, unevenly. Measure forty-five minutes. Changing the rate instead of reading the length Easy
The Bridge and the Torch Four people, one torch, a bridge that holds two. Everyone across in seventeen minutes. Making the expensive steps overlap Medium
One Poisoned Bottle in a Thousand A thousand bottles, one poisoned, one day to find it. Ten testers are enough. Reading an answer in binary Hard
A Hundred Prisoners and Their Hats A line of a hundred, each guessing their own hat colour. Ninety-nine can be saved for certain. Broadcasting one bit of parity Hard
Two Guards and Two Doors One guard always lies, one always tells the truth, and you get one question. Composing a liar with a liar Easy
One Question to the Islander Knights always lie or always tell the truth. One question, one road. Building a question whose answer is the same from either Hard
Three Mislabelled Boxes Three boxes of fruit, every label wrong. One fruit drawn fixes all three. Using a guarantee that every label is wrong Medium
A Spoonful Each Way A spoon of wine into the water, a spoon of the mixture back. Which glass is purer? Conserving volume instead of tracking molecules Hard
The Monk on the Mountain A monk climbs on Monday and descends on Tuesday. Is there a spot he passes at the same time? Superimposing two journeys into one Medium
Ten Hats in a Line Ten prisoners in a line guess their own hat colour. How many can be saved? Spending one answer to carry a parity Hard
Who Keeps the Fish? Five houses, five nationalities, five drinks, five pets, and nine clues. Driving a grid to a unique solution Hard
The Blue-Eyed Islanders A visitor says something everybody already knew, and a hundred people leave. Distinguishing what everyone knows from common knowledge Hard
When Is Cheryl's Birthday? Albert knows the month, Bernard knows the day, and their confusion gives it away. Deducing from what someone else does not know Hard
One Switch, A Hundred Prisoners A hundred prisoners, one light switch, and no way to speak. They can still count. Building a counter out of one bit of shared state Hard
Four Cards and a Rule Which two cards must you turn over? Most people get this famously wrong. Testing a rule by trying to break it Medium
The Unexpected Examination A teacher promises a surprise test. The class proves it cannot happen. It happens. Finding the flaw in a chain of reasoning Hard
Who Shaves the Barber? He shaves every man who does not shave himself. So who shaves him? Spotting a definition that cannot describe anything Medium
The Stamps on Their Foreheads Each sees the others' stamps but not their own. Nobody knows — until they do. Deducing from what others fail to deduce Hard
The Brakeman, the Fireman and the Engineer Three railwaymen, three passengers of the same names, and one deduction. Working a grid from negative clues Hard
Two Consecutive Numbers Each sees the other's number. Both say no, repeatedly — then one knows. Building a ladder of "he would have known" Hard
The Other Envelope Swapping always seems to gain 25%. So does swapping back. Something is wrong. Finding the flaw in an expected-value calculation Hard
One Question, Two Roads A fork, a stranger who may lie or may not, and one question. Composing a question that survives either answerer Medium
This Sentence Is False True makes it false and false makes it true. The answer is neither. Recognising a sentence that cannot have a truth value Medium
Three Hats, Two Colours Two can see and say nothing. The one who cannot see answers. Using other people's hesitation Medium

Mathematical puzzles

These do need a calculation, but never a hard one. The work is in deciding what to calculate: which worst case to balance, which trips to count, which possibilities the other person has already ruled out.

Puzzle What it tests Difficulty
Twenty-Five Horses Five at a time, no stopwatch. Find the fastest three in seven races. Eliminating by transitivity Hard
Two Eggs and a Hundred Floors Find the floor an egg survives, with only two eggs and a worst case to minimise. Balancing the worst case Hard
The Camel and the Bananas Three thousand bananas, a thousand kilometres, and a camel that eats as it walks. Spending where the rate is worst Hard
The Ages of the Three Daughters The product is 36, the sum is on the door, and the eldest plays the piano. Information in what somebody could not work out Medium
The Frog in the Well A frog climbs three feet a day and slips two at night. A thirty-foot well. Noticing the last step is not followed by a slip Easy
The Lily Pads Lily pads double daily and cover the lake on day 48. When is it half covered? Running a doubling backwards Easy
The Bat and the Ball A bat and ball cost £1.10. The bat costs £1 more than the ball. Writing the equation instead of answering by feel Easy
Five Machines, Five Widgets If 5 machines make 5 widgets in 5 minutes, how long do 100 take to make 100? Finding the rate of one machine Easy
Eight Pieces, Three Cuts Cut a round cake into eight equal pieces using only three straight cuts. Remembering that a cake has a third dimension Medium
The Tower of Hanoi Eight discs, three pegs, never a larger disc on a smaller. 255 moves. Building a recurrence from a single idea Medium
Wheat on the Chessboard One grain on the first square, doubling each time. The king cannot pay. Feeling the size of a doubling Medium
Chickens and Rabbits Thirty-five heads and ninety-four legs in the yard. How many of each? Two unknowns from two totals Easy
The Monkey and the Coconuts Five sailors each take a secret fifth, with one coconut always left for the monkey. Solving a chain of divisions with remainders Hard
The Bookworm Ten volumes on a shelf and a worm boring straight through. Not ten volumes' worth. Looking at where the pages actually are Medium
Three-Penny and Five-Penny Stamps With 3p and 5p stamps, 7p is the largest amount you cannot make. Finding where a gap sequence stops Medium
All the Gifts in the Song A partridge every day, twelve drummers once. How many presents altogether? Summing a sum Easy
The Ant on the Rubber Band The band stretches a kilometre a second. The ant crawls a centimetre. It still arrives. Tracking a fraction rather than a distance Hard
Every Third Man in the Circle Forty-one in a ring, every third one out. Where do you stand to be last? Turning a long process into a recurrence Hard
Fibonacci's Rabbits One pair, breeding by a fixed rule. How many pairs after a year? Reading a rule off a description Easy
A Penny, Doubled Every Day A million pounds now, or a penny that doubles every day for a month? Feeling the size of repeated doubling Easy
Folding Paper to the Moon A sheet 0.1 mm thick, folded in half again and again. Forty-two folds. Counting doublings with a logarithm Medium
The Hotel With No Vacancies Every room of an infinite hotel is full. A guest arrives. There is room. Taking "infinite" literally rather than as "very large" Medium
Achilles and the Tortoise By the time he reaches where it was, it has moved. So he never catches it. Seeing that infinitely many steps can take finite time Medium
How Far Over the Edge? Stack books on a table edge. How far past the edge can the top one reach? Stacking from the top down Hard
How Many Ways to Make a Pound? Seven coins, one pound, and four and a half thousand ways to get there. Counting combinations without listing them Medium

Questions people ask

Why do interviews ask puzzles?

Less often than they used to, and rarely to see whether you get the answer. What an interviewer is watching is how you start on something you have not seen before: whether you ask what the constraints are, whether you try a smaller version first, and whether you say what you are thinking. Silence followed by a correct answer scores worse than thinking aloud and getting most of the way.

Is it worth memorising the classic ones?

Only up to a point. The classics are worth knowing because the technique in each one - pigeonhole, invariants, working backwards from the end state, weighing to split a set in three - transfers to puzzles you have not seen. Memorising the answer without the technique leaves you with nothing the moment the numbers change.

What if I cannot solve one?

Read the working, then close it and solve it again from scratch a day later. A puzzle you have read the answer to is not a puzzle you can do.