Foundational puzzles that test structured reasoning
Most interview logic puzzles yield to one of five moves: find an invariant; look at the extreme object, or count one thing two ways; count what a budget of trials can certify; change the frame; compute a different quantity.
Statement. Let be a function of the state. If every legal move preserves , then is an invariant, , and any target with a different value is unreachable; a strictly decreasing, bounded-below integer (a monovariant) forces termination. Candidates: a count mod 2; a colouring (chessboard weights ); a sum mod ; a product; a gcd. Sign flips are parity: meshed gears alternate, so the -th gear in a chain turns as relative to the first (closing the chain into a ring is Gear Train Parity).
Worked instances. Seven coins lie heads up; a move flips exactly two. All tails? The number of heads changes by , or , so its parity is invariant: odd at the start, even at the target. Colouring: a knight changes square colour every move, so a board has no closed knight's tour (a closed tour has 25 moves, odd).
Check your understanding
Return to the seven coins, all heads up, but change the move: it now flips exactly three coins. Can you reach all tails?
Extremal principle. A finite nonempty set has a largest, smallest or most constrained element; extremality plus the local rule usually yields a contradiction.
Worked instance. Can every member of a finite set of reals be the average of two other members? Take the largest, . Two other members are both smaller, so their average is smaller than : impossible. An infinite set can (all integers).
Pigeonhole principle. objects in boxes: some box holds at least .
Worked instance. Any numbers from contain two coprime ones: the boxes receive numbers, so one gets two consecutive integers, which are coprime.
Counting two ways. Summing the degrees of a graph counts each edge twice, so : four nodes of degree 3 and six of degree 2 give edges. So the sum is even, which alone settles some existence questions (Phone Connection, Segment Intersection).
Optimality: a bound and a construction. A maximum or minimum needs two halves: a bound (pigeonhole, an invariant, counting) and a configuration attaining it. Non-attacking rooks on an board: two in one row attack, so at most 8; the diagonal attains it. Without a clean bound, use an exchange argument: if any configuration lacking a property can be improved locally, an optimum has it. Coins in stacks, product of sizes: splitting a stack of into and multiplies the product by , so no optimal stack exceeds 4; what remains is practice (Maximize Product).
Working backwards. When the end is fixed, invert the moves from it. At each of three gates a traveller hands over half his apples plus one, and leaves with 1: he had before the third gate, before the second, at the start. Integrality at each backward step often decides.
Search with a budget. Count how many cases trials can separate in the worst case, then build a strategy meeting it. Eggs: floors, unknown highest safe floor ; a drop from above breaks the egg, otherwise it is reused. Let be the most floors that eggs and drops can handle. One egg scans upward, . Otherwise drop as high as a break can still be recovered from: the floors below need , those above need , so
Worked instance. Two eggs, 10 floors: gives , so 4 drops: from 4, 7, 9, 10, scanning upward between the last two after a break. Summing the recursion for two eggs, and iterating it for three, is practice.
Elimination with limited comparisons. Picking the fastest few out of many with races of a fixed size is the same budget idea with a different ledger: a race certifies provable losses instead of floors. Lateral Thinking works it as selection by tournament; Horse Racing (25 horses, five lanes, top three) is its practice.
Idea. Choose the frame in which the motion is simplest: in the water's frame, or one mover's, separations change at the velocity difference. Symmetry: a line through the centre of a centrally symmetric region halves its area, so a rectangular cake with a rectangular hole is halved by the cut through both centres.
Frame change. You row upstream at still-water speed against a current ; your hat falls in, you notice 10 minutes later and turn instantly. In the water's frame the hat is at rest and you moved away at for 10 minutes, so you return in 10 minutes, whatever and are (constant speeds).
Relative angular speed. The minute hand turns 6 degrees per minute, the hour hand 0.5. Each hand's angle is linear in the minutes past twelve, so set up the lead and reduce it mod 360 (fold to at most 180 when the smaller angle is wanted). At 4:40 the minute hand is at degrees, the hour hand at : 100 degrees apart.
Idea. Identify the quantity the answer actually depends on, and compute that.
Circumference. , so lengthening a loop by raises it by all round; has dropped out. Lifting a belt 1 cm clear of a wheel everywhere needs cm more belt.
Trailing zeros of . Each is a factor and twos outnumber fives, so count factors of 5 among : one per multiple of 5, a second per multiple of 25, a third per multiple of 125. For : six multiples of 5 plus a second five from 25, so 7 zeros.
Factorial versus exponential. Pair with : for , so and ; the same pairing bounds from above (Factorial Vs Exponent). Against a fixed base , each factor multiplies the ratio by , so eventually wins; for the crossover is . For two large powers, take logarithms or squeeze both between powers of a common base; for two logarithms, check monotonicity.
n! versus 10ⁿ on a log scale: 10ⁿ leads up to n = 24, n! from n = 25 on
The comparison from the paragraph above, drawn as so both regimes fit on one axis: the curve is below the zero gridline where is larger and above it where is larger. Going from to multiplies the ratio by the factor , so each segment's slope is : negative up to , exactly flat between the two dots at and (the factor is ), which is where the minimum sits, then positive and steeper at every step. Look at how deep the dip is before recovers: at the minimum the log ratio is , so is about 2760 times smaller than , and the catch-up takes 15 more factors. The dashed line marks the crossover the text quotes: is still below 1 and is the first ratio above 1.
Interview insight. Name the method before the answer ("a parity invariant"). If stuck, announce the tiny-case plan and start it: interviewers grade process; a correct small table earns partial credit.