Brainteasers
Short logic puzzles that test how you reason under time pressure, each solved step by step.
01Angle on the clock
What is the smaller angle between the hour hand and the minute hand of a clock at 3:40?
Hint
The hour hand moves too: half a degree per minute.
Answer
The smaller angle is 130 degrees.
Solution
The minute hand stands at 40 × 6 = 240 degrees from the 12.
The hour hand stands at 3 × 30 + 40 × 0.5 = 110 degrees.
The difference is 130 degrees. It is below 180, so it is already the smaller angle.
02The light memory stick
You have 8 memory sticks that look identical. Seven weigh the same, and one is slightly lighter. Using a balance scale with two pans, what is the smallest number of weighings that always finds the light stick?
Hint
A weighing has three possible outcomes. Use all three.
Answer
Two weighings always suffice, and one weighing never does.
Solution
Put 3 sticks on each pan and keep 2 aside.
If one pan rises, the light stick is among its 3. Weigh one of them against another: the lighter one is it, and a balance points to the third.
If the pans balance, the light stick is one of the 2 set aside, and one more weighing of them against each other finds it.
One weighing is never enough, because it has only 3 outcomes and there are 8 candidates.
03Fifteen coins
Fifteen coins lie on a table, all heads up. In one move you must turn over exactly four coins of your choice. Can you reach a position where all coins show tails?
Hint
Watch how the number of heads can change in a single move.
Answer
No, it is impossible.
Solution
Say a move turns over h heads and 4 - h tails. The number of heads then changes by (4 - h) - h = 4 - 2h, which is always even.
So the number of heads stays odd after every move, because it starts at 15.
All tails means 0 heads, an even number, so that position can never be reached.
04Erasing pairs
The numbers 1 to 10 are written on a board. In each step you erase any two numbers a and b and write their difference |a - b| instead. After nine steps a single number is left. Can it be 0?
Hint
Look for a quantity that never changes its parity from one step to the next.
Answer
It can never be 0, because the last number is always odd.
Solution
The numbers a + b and |a - b| differ by an even amount, so they have the same parity.
Each step therefore keeps the parity of the sum of all numbers on the board.
The starting sum is 1 + 2 + ... + 10 = 55, which is odd.
So the final number is odd and can never be 0.
05Thirty stones
A pile has 30 stones. Two players take turns, and on each turn a player removes 1, 3 or 4 stones. Whoever takes the last stone wins. Would you rather move first or second, and how do you play?
Hint
Work backwards from small piles. Mark each pile as a win or a loss for the player who is about to move.
Answer
The second player wins. A pile is lost for the player to move when it leaves a remainder of 0 or 2 after division by 7, and 30 leaves 2.
Solution
A pile is lost for the player to move if every legal move leaves a winning pile for the opponent. The empty pile counts as lost, since the last stone is already gone.
Working up from there: 1 wins, 2 loses (the only move leaves 1), 3 and 4 win, 5 wins (take 3, leave 2), 6 wins (take 4, leave 2), 7 loses.
From then on the pattern repeats every 7 stones. The losing piles are 0, 2, 7, 9, 14, 16, 21, 23, 28 and 30.
So let the opponent start at 30. After each of their moves, take enough stones to leave a remainder of 0 or 2 again.
win = [False] * 31 for n in range(1, 31): win[n] = any(n >= k and not win[n - k] for k in (1, 3, 4)) print([n for n in range(31) if not win[n]]) # [0, 2, 7, 9, 14, 16, 21, 23, 28, 30]06Two piles, two kinds of move
Two piles hold 5 and 8 stones, and two players take turns. A move either takes any positive number of stones from one pile, or takes the same positive number from both piles. Whoever takes the last stone wins. Should you move first, and which first moves win?
Hint
Find the losing pairs one at a time, starting from (0, 0). Each new losing pair uses the smallest number that has not appeared yet.
Answer
The first player wins. Both winning moves lead to a losing pair: take 5 from the pile of 8, leaving (5, 3), or take 1 from each pile, leaving (4, 7).
Solution
A pair is losing for the player to move if every move from it reaches a winning pair. (0, 0) is losing.
No losing pair can reach another one in a single move. So no two losing pairs share a pile size or the same difference between the piles.
Building them up in order gives (0, 0), (1, 2), (3, 5), (4, 7), (6, 10) and (8, 13). The differences are 0, 1, 2, 3, 4 and 5.
The pair (5, 8) is missing from that list, so the first player wins.
From (5, 8), taking 5 from the larger pile gives (5, 3), the same as (3, 5). Taking 1 from both gives (4, 7). No other move reaches a losing pair.
from functools import lru_cache @lru_cache(None) def wins(a, b): moves = [(a - k, b) for k in range(1, a + 1)] moves += [(a, b - k) for k in range(1, b + 1)] moves += [(a - k, b - k) for k in range(1, min(a, b) + 1)] return any(not wins(*m) for m in moves) print(wins(5, 8)) # True
Full collection This category has 13 more questions with worked solutions (5 easy, 4 medium, 4 hard). They open with Pro. See pricing, or sign in to your account.
Compare your own answer with the worked solution.