Courses / How to pass interviews with puzzles
You have two ropes and a lighter. Each rope burns for exactly one hour, but unevenly: half a rope does not necessarily burn in half an hour. How do you measure 45 minutes?
"Take your time. Think out loud, I'm interested in how you reason."
You might get a puzzle like this in an interview for a quant firm, consulting, analytics or software. This course is about what to do in those ten minutes. First we learn to reason out loud: read the question, try small cases, work backwards, estimate and shape an answer. Then we build a toolkit: what one test tells you, the worst case, invariants, a smart schedule. The third part is about probability and what to do when you're stuck. At the end comes a mock interview with a timer and hints, and the rope puzzle worked through.
≈ 1.5–2 hours, in 10–15 minute parts if you like; your progress is saved.
Six habits an interviewer notices in the first minutes. Each chapter starts with a small puzzle: guess first, then check it on a live picture. Arithmetic is enough here.
"They'll give me a puzzle. What if I don't know the answer?"
An interview puzzle is not an exam with the answer at the back of the book. The interviewer has ten minutes to see how you think and write it down. The answer matters, but it is just one line in their notes.
Two candidates get the same puzzle. A thinks silently for a minute and names the right number; asked "how did you get it?", A says they knew the puzzle. B thinks out loud, makes a mistake, notices it, fixes it and checks the answer on a small example. Who most likely gets the higher score?
The puzzle: "How many squares in total can you see on an 8×8 chessboard?"
(a minute of silence)
— 204.
— How did you get that?
— I knew this one.
clarifying— We count squares of any size made of cells? So the whole board too?
simple case— 1×1 squares: 64. A 2×2 square fits in 8 positions along a row... no, 7, since it takes two cells. So 7×7 = 49.
pattern— Looks like there are (9 − k)² squares of size k×k. Then the total is 64 + 49 + … + 1, the sum of squares from 1 to 8, which is 204.
check— Let me check on a 2×2 board: the formula gives 4 + 1 = 5. Counting by hand: four small ones and one big. It matches.
Both got 204. But A's notes will say one word, "knew", while B's will show four signals, and those are what B is scored on.
Are puzzles asked at all? It depends on where you're going. Big tech companies have mostly dropped brainteasers: in 2013 Laszlo Bock, then Google's head of people operations, told the New York Times that their own data showed brainteasers did nothing for hiring. But at quant firms and trading houses, probability and logic puzzles are still a normal part of the interview, consulting asks for rough estimates, and software and analytics interviews ask algorithm and probability questions that are easy to mistake for a brainteaser.
"The answer is obvious. Why is the interviewer smiling?"
The most common interview mistake is not hard maths but a quick answer to a different question than the one asked. The brain slips in a familiar template, and out comes a confident but wrong number.
A notebook and a pen cost 130 hryvnias together. The notebook costs 100 more than the pen. How much is the pen?
Ten seconds of this check save you from the most painful mistake: confidently stating a number that doesn't satisfy the question.
The other half of reading the question is asking the interviewer. Many classic puzzles change their answer because of one easily missed detail. Here is the Monty Hall problem. Tap the underlined words: each is an assumption worth saying out loud.
You're on a game show and pick one of three doors. Behind one is a car, behind two are goats. The host, , and . Should you switch?
Deeper: the classic version of the notebook puzzle, and the Monty Hall problem, with a game and a simulation.
A bat and a ball cost $1.10 together. The bat costs a dollar more than the ball. How much is the ball?
You're on a game show and pick one of three doors. The host, who knows where the car is, opens another door to reveal a goat and offers a switch. Should you take it?
"A hundred people, a hundred steps. How do you even hold that in your head?"
Big numbers in a question are often only there to scare you. If you can't see the puzzle at once, solve it for 1, 2, 3, 4 and look at the answers. A pattern usually shows by the fifth step, and explaining it is easier than guessing it.
A corridor has 100 closed lockers. The first student opens them all. The second toggles every second one (2, 4, 6, …): closes an open one, opens a closed one. The third toggles every third, and so on up to the hundredth, who toggles only the hundredth. How many lockers are open at the end?
Why squares? Locker 12 is touched by students 1, 2, 3, 4, 6 and 12, its divisors. Divisors come in pairs: 1 and 12, 2 and 6, 3 and 4, so the locker is toggled an even number of times and ends closed. Only a square has an unpaired divisor: for 16, the divisor 4 pairs with itself. Small cases gave the pattern, and the explanation turned it into a proof.
Deeper: two puzzles where small cases are the only way in.
A visitor tells the islanders what they already knew: "I can see someone with blue eyes." Can that change anything?
Each of 100 prisoners may open 50 of 100 boxes to find their number. All go free only if every one succeeds. What are the odds with the best strategy?
This builds on what you haven't done yet: chapter 3, “Small cases”
"This is a game of many moves. Where do I start?"
When a puzzle is a sequence of steps, starting from the first is often hopeless: there are too many options. The last step, though, is usually simple. Solve it, then the one before, and so on back to the start. It's the same "small cases" idea, except that what's small here is the end of the game.
There are 21 matches on the table. Two players take turns taking 1, 2 or 3 matches. Whoever takes the last one wins. You get to choose. What do you do?
Now from the end. A position with 0 matches is lost for the player to move: they have already lost. From 1, 2, 3 you can take everything and win. From 4, any move leaves the opponent 1, 2 or 3, so 4 is lost again. Press to colour the rest.
Black cells are positions lost for the player to move.
Deeper: pirates who split gold from the end, and a lake best read from its last day.
Five logical pirates split 100 coins, and a captain whose split is not backed by half the crew goes overboard. How many coins does he keep?
Duckweed doubles every day, and one plant covers a lake in 30 days. How long do two plants take?
"How would I know how many there are? I don't remember numbers like that."
Estimation questions, also called Fermi questions, don't test your memory. They are asked to see how you break an unknown number into a few known ones, state your assumptions and check that the result is plausible. Being within a factor of two is usually more than enough.
How many babies are born in the world in one day?
The idea: everyone was born once. If the population is roughly steady, the number born each year is how many people "turn over" in a year: the population divided by the length of a life.
Data: Our World in Data, from the UN World Population Prospects 2024: 132.1 million births in 2023, a population of 8.09 billion, life expectancy 73.2 years.
With the real numbers the estimate gives about 300 thousand a day, about a sixth short of the truth. That gap is interesting too, and worth saying aloud: the population is not steady but growing, so there are more young people than in a steady world, and they have more babies. Saying which way your estimate may be off and why is the best way to finish an answer.
Deeper: a puzzle where the sense of scale fails almost everyone.
A rope around the equator is made 1 metre longer and lifted evenly. How big is the gap between it and the ground?
This builds on what you haven't done yet: chapter 1, “What is really rated”
"Five minutes in and I still don't see a solution. What do I say?"
A dead end in an interview is a normal part of the puzzle, not a failure. Interviewers often deliberately pick a puzzle few people finish in ten minutes, to see what you do when you don't know.
You're stuck five minutes in and have been silent for a minute. What's the best move?
If you're stuck, go back to step 4 and say so: "I'm stuck here, let me try it for two."
Four ideas behind most logic puzzles in software and quant interviews: how much one test tells you, the worst case, invariants, and a smart schedule. You'll need powers of two and a little patience.
"Hundreds of thousands of candidates and only a handful of tests. Is that even possible?"
Many puzzles ask: how many tests do you need to find one item among many, for sure? Instead of trying strategies, count how many different outcomes your tests can produce together. If there are fewer outcomes than possibilities, no strategy will help. If there are as many or more, it can usually be done.
You've picked one word from a dictionary of 100,000 words. I ask questions that can only be answered "yes" or "no". How many questions do I need to find the word for sure?
I'll find it in at most 10 questions, since 210 = 1024. Answer honestly.
–
What if a test has three outcomes instead of two? A balance shows "left heavier", "right heavier" or "equal", so n weighings give 3n different outcomes. It gets more interesting when several tests run at once: then you count not questions but combinations of all the tests' answers together. Both puzzles below come down to exactly this count.
Deeper: two classic puzzles about counting outcomes.
One of 1,000 bottles of wine is poisoned, and the rats can test it in one round only. How many rats do you need to find the poisoned bottle for sure?
One of 12 coins is fake, lighter or heavier, nobody knows. How many weighings on a two-pan balance do you need to find it for sure and say which way it is off?
This builds on what you haven't done yet: chapter 7, “What one test tells you”
"Binary search is the best, surely. Why doesn't it work here?"
"For sure" in an interview means "in the worst case". It helps to imagine an evil opponent who knows your strategy and always answers so as to hurt you most. A strategy is good if even they can't force you into more steps.
A 10-floor building and two identical eggs. From some floor up, eggs break; below it they don't. A broken egg is gone; an intact one can be dropped again. How many drops do you need in the worst case to find the highest safe floor for sure?
The building doesn't decide in advance which floor breaks eggs. It answers so that you have to keep dropping as long as possible, but never contradicts itself. Press floors.
Deeper: the same idea with 100 floors, and in a horse tournament without a stopwatch.
A 100-floor building and only two eggs. How many drops do you need in the worst case to find for sure the highest floor from which an egg does not break?
25 horses, a track for only 5 and no stopwatch. How many races do you need to find the three fastest horses and their order for sure?
"I keep trying and there's always a gap left. Am I doing something wrong?"
An invariant is a quantity that doesn't change whatever you do. If it would have to be different at the end than at the start, the goal is unreachable, and you don't need to try every option to prove it. In an interview it is the shortest path from "I can't make it work" to "it's impossible, and here's why".
Two opposite corner squares are cut out of an 8×8 chessboard, leaving 62 squares. Can you cover them with 31 dominoes, each covering exactly two adjacent squares?
Place a domino: tap two adjacent squares. Tapping a placed domino removes it.
Deeper: a hundred people, hats and one parity for everyone.
100 people in a line in black and white hats see only those in front of them. How many can surely name the colour of their own hat?
This builds on what you haven't done yet: chapter 6, “Shaping an answer”
"I'll just do the best thing at each step. What could go wrong?"
A greedy strategy, always doing what looks best right now, is a natural first step and a good "first rough answer" from chapter 6. But in scheduling puzzles it often loses, and a lower bound helps you check: the least time it could possibly take, however you arrange things.
A toaster fits two slices of bread and toasts one side of each per minute. You need three slices toasted on both sides. Flipping and swapping slices takes no time. What is the shortest time?
Pick up to two slices and press "A minute passes": each picked slice gets one more side toasted.
Deeper: a bridge at night, a torch, and a puzzle where greed loses.
Four people must cross a bridge for two at night with one torch. They take 1, 2, 5 and 10 minutes. What is the least time for the whole crossing?
Three intuition traps loved in quant and analytics interviews: conditional probability, the average, and when to stop. You'll need fractions and the idea of an average. The last chapter of the part is about taking a hint when no tool works.
This builds on what you haven't done yet: chapter 2, “Read the question again”
"Two options are left, so it's fifty-fifty?"
"Two options, so it's half and half" is the most common mistake in probability puzzles. Options aren't always equally likely: what matters is not how many are left but how many ways you could have arrived at what you see.
A bag holds three cards: one red on both sides, one white on both sides, one red on one side and white on the other. You draw a card at random and put it on the table. The top side is red. What is the chance the bottom is red too?
Deeper: two puzzles where "half and half" is a trap.
You're on a game show and pick one of three doors. The host, who knows where the car is, opens another door to reveal a goat and offers a switch. Should you take it?
A family has two children, and at least one of them is a boy. What is the chance both are boys? And what if at least one of them is a boy born on a Tuesday?
"There are so many cases. Do I really have to go through them all?"
In average puzzles you often don't need the full distribution. It's enough to split the quantity into a sum of simple parts: the average of a sum is the sum of the averages, even when the parts depend on each other. And symmetry gives each part's average with no calculation at all.
Ten people check their hats, and the attendant hands them back completely at random. How many people get their own hat back, on average?
The bars show in how many evenings exactly 0, 1, 2, … people got their own hat.
Look at the last number: in about 37% of evenings nobody gets their own hat, so at least one person does in 63%. That's the second trick of this chapter: when asked "at least one", compute the opposite, "none", and subtract it from one. That is how the birthday problem is solved too.
Deeper: a sticker album whose average is a sum of simple parts, and a room where "at least one pair" is computed through "none".
An album has 50 slots, and the stickers in the packs are random. On average, how many stickers do you have to buy to fill it?
How many people must be in a room before two of them probably share a birthday?
This builds on what you haven't done yet: chapter 3, “Small cases”
"Take the first offer or wait for a better one?"
Stopping puzzles are like life: options arrive one at a time, a rejection can't be undone, and nothing is known about those still to come. The big case isn't visible at once, so we start small (chapter 3): three candidates have only six possible orders, few enough to list by hand.
Three candidates arrive in random order. You must decide on each at once: hire, or reject forever. You only see whether they're better than those before. Which strategy hires the best one more often?
1 is the best candidate, 3 the weakest. Orders read left to right.
Deeper: the same with a hundred candidates.
100 candidates arrive one at a time, and you must decide on each one on the spot. What chance of hiring the best?
This builds on what you haven't done yet: chapter 2, “Read the question again”chapter 3, “Small cases”chapter 9, “Invariants and parity”
"I was given a hint. Does that count against me?"
A hint is an ordinary part of the conversation: the interviewer gives it to keep the puzzle moving and to see more. What's rated is not that you needed it but what you did with it: whether you saw where it points and connected it to what you had already tried.
You've been turning over a puzzle about a hundred items for a few minutes, and the interviewer asks: "What if there were only two?" What does that most likely mean?
There are 100 coins on the table, 10 of them heads up. You're blindfolded: you can't see the coins or feel which side is up, but you can move and flip them. Split the coins into two piles with the same number of heads.
Hint 1What if there were two coins, one of them heads up?
Hint 2The piles needn't be the same size. How many coins should go in the smaller one?
Hint 3If a pile of 10 coins has k heads, how many heads will it have once you flip all ten?
Notice what each hint did: the first was a small case (chapter 3), the second removed an unnoticed constraint (chapter 2), the third was an invariant: the difference in heads between the piles stays under your control (chapter 9). Interview hints almost always point to one of this course's tools. So when you hear one, say which technique it points to and how it changes your plan.
Four new puzzles, as in a real interview: with a timer, a hint ladder and a self-review. We rate not only the answer but how you got there.
This builds on what you haven't done yet: chapter 2, “Read the question again”chapter 5, “A rough estimate”chapter 6, “Shaping an answer”chapter 7, “What one test tells you”chapter 12, “Symmetry and the average”
"You have five minutes per puzzle. Think out loud."
How to practise: start the timer and solve out loud, to a voice recorder or a friend. If you're stuck, take the next hint, as you would from an interviewer. Then pick an answer and honestly tick what you did along the way. Each puzzle trains a chapter of the course.
Puzzle 1 · an estimate
How many times does a human heart beat in 80 years of life?
Split it into two numbers: beats per minute and minutes in a life.
At rest an adult heart beats 60–100 times a minute. Take 70.
A year has 60 × 24 × 365 ≈ 525,600 minutes, about half a million.
Puzzle 2 · tests
There are 8 identical-looking balls, one slightly heavier. How many weighings on a balance with no weights do you need to find the heavy one for sure?
How many different outcomes can one weighing show?
Three: left heavier, right heavier, equal. Two weighings give 3 × 3 = 9 outcomes, and there are 8 balls.
Put 3 balls on each pan and set 2 aside.
Puzzle 3 · a simpler view
Two trains 100 km apart head towards each other, each at 50 km/h. A fly flies from one train to the other at 75 km/h, turns around, flies back and so on until the trains meet. How many kilometres does the fly cover?
Don't add up the flight legs one by one: there are infinitely many.
Which is easier to find: the fly's path, or how long it flies?
The trains close in at 100 km/h. How long until they meet?
Puzzle 4 · an average
You toss a fair coin until two heads come up in a row. How many tosses does it take on average?
Name the states: "from scratch" and "just got a head".
Let E be the average number of tosses from scratch and F after one head. What happens after the next toss in each state?
E = 1 + ½·F + ½·E, and F = 1 + ½·0 + ½·E.
Two ropes, each burns for exactly an hour, but unevenly. How do you measure 45 minutes?
Here's how a strong answer might sound. Each line is a habit from the course.
Practising on catalogue puzzles is easy in the "Interview trainer": a random puzzle, a timer, three hints and a self-review of your reasoning.
All books with the chapters where catalogue puzzles appear are on the site's shelf.