What interviewers want from a brainteaser
Logic puzzles test whether you can find structure under time pressure. Most of them yield to one of five ideas. When you are stuck, try each in turn and say which you are trying.
- Invariants and parity. Find a quantity that never changes, and show the goal would change it.
- Relabelling and symmetry. Describe the same process in a way that makes it trivial.
- Information counting. Count how many outcomes must be distinguished and how many each test can separate.
- Pigeonhole. If objects go into boxes, two share a box.
- Small cases and extremes. Solve , look for the pattern, then prove it.
Worked example
the mutilated chessboard
Remove two diagonally opposite corner squares from an chessboard. Can the remaining 62 squares be covered by 31 dominoes, each covering two adjacent squares?
Show solutionHide solution
No. Every domino covers one black and one white square, so any tiling covers equally many of each. Opposite corners have the same colour, so the board has 32 squares of one colour and 30 of the other. The colour count is the invariant.
Relabelling
Some processes look complicated only because we track the wrong objects. In the classic ant puzzle, two ants bouncing off each other look exactly like two ants passing through each other with their labels swapped. If you only care about when the last ant leaves, labels do not matter, so you may pretend the ants pass through each other and each walks straight off the end.
Similar tricks: in a knockout tournament with players, every game eliminates exactly one player, so there are always games. To count handshakes, count ordered pairs and halve.
Information counting
If a test has possible results, then tests can distinguish at most cases. This gives a lower bound on the number of tests, and often a hint for the construction.
A balance scale has three results (left heavy, right heavy, balanced). Finding one heavier coin among 9 needs at least weighings, and two suffice: weigh 3 against 3, then 1 against 1 within the heavy group (or the unweighed group if balanced).
For the famous 12-coin problem (one coin is heavier or lighter), there are cases and , so three weighings might work, and they do, with careful design. A yes/no question has 2 results, so it can at most double your chance of guessing a hidden outcome.
Pigeonhole and extremes
Pigeonhole: among any 5 points in a unit square, two are within of each other. Divide the square into four quarter-squares; two points share one, and the diagonal of a quarter is .
Extremes and burning tricks: a rope that burns in 60 minutes, lit at both ends, burns out in exactly 30 minutes however unevenly it burns, because the two flames together consume the whole rope's worth of burning time. Look for an operation that removes the unknown.
Small cases: "how many pieces from straight cuts?" Count 1, 2, 4, 7 and notice the -th cut can add at most pieces, since it crosses at most earlier cuts.
Worked example
the hands of a clock
How many times in 24 hours do the hour and minute hands of a clock point in exactly the same direction?
Show solutionHide solution
The minute hand turns at 360° per hour and the hour hand at 30° per hour, so the minute hand gains a full lap on the hour hand every hours. In 24 hours that happens times. (The overlap at midnight is counted once.)
Knowledge check
100 lockers start closed. Person k toggles every k-th locker, for k = 1 to 100. How many lockers are open at the end?
Knowledge check
One of 27 coins is heavier than the rest. What is the minimum number of weighings on a balance scale that guarantees finding it?
Knowledge check
A single-elimination tennis tournament has 113 players, with byes as needed. How many matches are played?
Practice problems
Finished reading?
Answer the 3 knowledge checks to complete this lesson (0 done).