Mathematics · Article
Puzzles, recreational mathematics and invention
Use recreational puzzles to develop reusable proofs about states, colorings, number systems, games, probability and symmetry.
Back to MathematicsAfter reading, you can
- Use an invariant to exclude a target and state exactly what the invariant proves.
- Construct and verify solutions using induction, position labels and residues.
- Compare the number of moves, elapsed time and information needed to solve a finite puzzle.
- Find winning positions in specified finite games using parity and xor.
- Compute exact puzzle probabilities when sampling, observation and stopping rules are stated.
- Use graph walks, orbits, reflection and complementary counts to create or solve related puzzles.
How a puzzle becomes a mathematical problem
A puzzle supplies initial information, a target and a rule for each allowed move. Write those rules before searching. When two boards look alike, a blank position, a move direction or an earlier announcement may still change the available choices.
The lesson moves from color and divisibility arguments to explicit state graphs, decision trees and finite games. Some proofs show that a target is unreachable. Others construct a solution and then bound the work or time any solution must use. A lower bound and a legal construction answer different questions and can meet at the optimum.
For a puzzle involving chance, state what is random and what information each observation reveals. The same care with conditions explains door choices, repeated labels and interrupted games. The final examples use symmetries to count arrangements or invent a whole family with a known strategy.
Color a board to test a domino tiling
Number the rows and columns by consecutive integers and color cell (i,j) by the parity of i+j. Horizontally or vertically adjacent cells differ by one in exactly one coordinate, so they have opposite colors.
A domino on the grid covers exactly such an adjacent pair. In any complete tiling, each tile therefore contributes one cell to each color count.
An even n-by-n grid has equal color counts because each row has n/2 of each. Removing two distinct cells of one color lowers just that color count by two.
The remaining board has an even number of cells but unequal counts. A tiling would force equality, so none exists in this case. When counts agree, that check has passed and a construction or another obstruction may still be needed. See [Reachability and preserved predicates](https://www.ocw.mit.edu/courses/6-042j-mathematics-for-computer-science-spring-2015/mit6_042js15_textbook2.pdf#page=144). Opposite colors are paired by each legal domino. The total remaining color imbalance therefore excludes the tiling.
Prove why the 1089 digit trick works
Let the first and last digits be a,c, and the middle digit be b. The three-place reversal exchanges a and c. The signed difference is (100a+10b+c)−(100c+10b+a)=99(a−c).
Subtracting the smaller number from the larger therefore gives 99d with d=|a−c| between one and nine. This difference has the three-place representation with digits d−1,9,10−d, since 100(d−1)+90+(10−d)=99d.
Even when d=1, keep the hundreds place zero. The reversed difference has value 100(10−d)+90+(d−1). Both the original difference and its reversal now use a declared convention.
The absolute difference equals 99 times the positive difference between endpoint digits. For distinct endpoints its padded reverse produces the complementary digit pattern and the sum 1089. Equal endpoints give difference zero.
| Quantity | Exact result |
|---|---|
| Original | 321 |
| Reversed | 123 |
| Difference | 198 |
| Reversed difference | 891 |
| Endpoint digits differ | True |
| Sum | 1089 |
Exact inputs and supporting calculations
| Parameter | Value |
|---|---|
| x | 321 |
Adding gives 99d+100(10−d)+90+d−1=1089. The middle digit b cancels at the first step. The fixed sum follows for every allowed pair of unequal end digits. See [Decimal places and expanded form](https://openstax.org/books/contemporary-mathematics/pages/4-1-hindu-arabic-positional-system). The place weights 100, 10 and 1 turn the ordered difference into 99 times the outer-digit gap. Preserve three positions while reversing.
Use alternating colors to test a closed knight tour
A standard knight move changes one coordinate by two and the other by one, with independently permitted signs subject to remaining on the board. The change in the coordinate sum is always odd.
Thus along any sequence of knight moves the board colors alternate. On a closed tour the final move returns to the initial color after an even number of moves.
Count the visited cells once each, leaving the repeated start at the end out of that count. Half the visited positions have the starting color and half have the other color. This holds for either choice of start.
A closed tour covering a board therefore requires equal numbers of the two colors. Write the side lengths as 2u+1 and 2v+1. The first row has one extra cell of its initial color, the second has one extra of the other, and the excess alternates through the last row. The whole board therefore has one extra cell of the initial color. The unequal full-board counts rule out a closed tour there. See [Reachability and preserved predicates](https://www.ocw.mit.edu/courses/6-042j-mathematics-for-computer-science-spring-2015/mit6_042js15_textbook2.pdf#page=144). A legal knight step flips coordinate-sum parity. A closed alternating cycle needs equal color classes among its distinct visited cells.
Track a sliding-tile invariant
Read a board of width w left to right along each row, top to bottom, and omit the blank. Let I be the number of pairs of distinct labels out of increasing order. Number the blank’s row r from the bottom starting with one.
A horizontal blank swap leaves the relative order of the nonblank tiles unchanged and leaves r unchanged. A vertical blank swap moves one tile past exactly w−1 other nonblank tiles in the flattened list.
Passing each such tile reverses that pair’s order and changes inversion parity once. Thus a vertical swap changes I by parity w−1 and changes r by one modulo two.
If w is odd, I modulo two is invariant. If w is even, I+r modulo two is invariant because both parts change together on a vertical swap. A target with a different invariant cannot be reached by the allowed moves. See [Legal moves and parity in the sliding puzzle](https://mathsmartinthomas.wordpress.com/wp-content/uploads/2014/10/archer_15_puzzle.pdf). The displayed exchange keeps the blank at the corner. Each vertical step crosses exactly width minus one other listed entries, which determines the preserved parity.
Tile a square with one missing cell
For k=1, the grid is two by two. Any three remaining cells after a single deletion form an L-shaped tromino.
For k>1 divide the board into four squares of side 2^(k−1). Exactly one of them contains the missing cell. The central two-by-two block of the whole board contributes one corner cell to each quadrant.
Place one tromino over the three central cells in the quadrants without the original deletion. The fourth central cell belongs to the quadrant that already lacks a cell, so it is left for the recursive step if present.
Now each quadrant has exactly one unavailable cell, either the original deletion or one already used by the central tromino. By induction tile the remaining cells of all quadrants independently. These four tilings and the central piece cover the required board without overlap. See [Strengthen the induction hypothesis to move the hole](https://www.ocw.mit.edu/courses/6-042j-mathematics-for-computer-science-spring-2015/mit6_042js15_textbook2.pdf#page=130). The strengthened induction hypothesis allows an unavailable cell in any location. One central piece arranges the four smaller induction cases.
Find exactly which quantities two jugs can measure
Let g=gcd(a,b), with 0<a≤b. Both contents start at zero, which is a multiple of g. Filling to capacity or emptying one jug preserves the property that both contents are multiples of g.
A pour moves the lesser of the source contents and the free space in the destination. If both contents are multiples of g, so are both candidate transfer volumes. Thus every attainable content remains a multiple of g.
For the converse, start a cycle with the smaller jug empty and with r<b in the larger. Fill the smaller, pour into the larger, and when the larger reaches capacity empty it and pour any remainder from the smaller. The new large-jug amount is (r+a) modulo b, and the smaller jug is empty.
The operations preserve multiples of the capacity gcd. Breadth-first discovery assigns the smallest number of unit-cost moves to each visited state.
| Quantity | Exact result |
|---|---|
| gcd | 1 |
| Reachable states | 16 |
| Target reached | True |
| Shortest actions | 6 |
| Path | (0, 0) → (0, 5) → (3, 2) → (0, 2) → (2, 0) → (2, 5) → (3, 4) |
Exact inputs and supporting calculations
| Parameter | Value |
|---|---|
| a | 3 |
| b | 5 |
| target | 4 |
| State | Distance |
|---|---|
| (0, 0) | 0 |
| (3, 0) | 1 |
| (0, 5) | 1 |
| (3, 5) | 2 |
| (0, 3) | 2 |
| (3, 2) | 2 |
| (3, 3) | 3 |
| (0, 2) | 3 |
| (1, 5) | 4 |
| (2, 0) | 4 |
| (1, 0) | 5 |
| (2, 5) | 5 |
| (0, 1) | 6 |
| (3, 4) | 6 |
| (3, 1) | 7 |
| (0, 4) | 7 |
Iterating from zero gives the residues ka modulo b. Writing a=ga′ and b=gb′ with coprime a′,b′ shows these cover every multiple of g below b because multiplication by a′ permutes residues modulo b′. Filling the larger directly also attains b. See [Fill, empty and pour as exact transitions](https://www.ocw.mit.edu/courses/6-042j-mathematics-for-computer-science-spring-2015/mit6_042js15_textbook2.pdf#page=147), [Find the greatest common measure](https://mathcs.clarku.edu/~djoyce/java/elements/bookVII/propVII2.html). The gcd condition follows from the allowed fills and pours. A complete modular orbit and the full-capacity endpoint supply the constructive direction.
Derive the every-second-token recurrence
Let J(n) be the surviving original label, with J(1)=1. In the first sweep of n=2m, the removed tokens are 2,4,…,2m. The remaining odd labels begin the next count again at one.
Relabel these m odd tokens consecutively, so new index j corresponds to old label 2j−1. The removal rule in the new labels is unchanged, giving J(2m)=2J(m)−1.
For n=2m+1 with m≥1, first remove the same even labels. The next count passes 2m+1 and removes one. The remaining labels 3,5,…,2m+1 start at three, so J(2m+1)=2J(m)+1.
Write n=2^s+ℓ with 0≤ℓ<2^s. For n>1, m=⌊n/2⌋=2^(s−1)+⌊ℓ/2⌋. Substituting the inductive J(m)=2⌊ℓ/2⌋+1 into the appropriate recurrence gives J(n)=2ℓ+1 for either parity. See [Relabeling a circular elimination recurrence](https://www.informit.com/content/images/9780201558029/samplepages/9780201558029.pdf#page=29). Relabeling the remaining odd original labels gives both recurrence branches. The rule starts counting at label one and removes label two first when n exceeds one.
Make a torch-crossing puzzle a finite cost problem
A state records the set of people already on the far side and the side holding the torch. A legal transition toggles the torch side and moves one or two available people from its side to the other. Its cost is the larger of their times, or the sole time for one person.
Set D₀ to zero at the initial state and to infinity elsewhere. If D_k records the least cost using at most k moves, D_(k+1)(s) is the minimum of D_k(s) and all values D_k(t)+cost(t,s) over legal edges into s.
This recurrence is exact because any path with a new last move reaches its predecessor in at most k moves. Conversely a predecessor path and that edge produce a legal candidate. Induction proves the intended meaning of every D_k.
With N distinct states, a shortest path can be chosen with no repeated state. Removing a cycle preserves the legal connections and strictly decreases its positive cost. Every least-cost solution is therefore found by the N−1 move bound, while infinite cost there certifies no solution. See [Crossing times and legal torch schedules](https://page.mi.fu-berlin.de/~rote/Papers/pdf/Crossing%2Bthe%2Bbridge%2Bat%2Bnight.pdf). The state includes the torch side and people on each side. Positive transition costs allow a minimum to be found among paths with no repeated state.
Bound the information from balance weighings
A balance weighing can give three outcomes. An adaptive procedure of depth at most k has at most 3^k outcome leaves, since each extra weighing can branch three ways. Earlier stops can be counted as leaves of the same depth bound.
Each possible heavier coin needs a different identifying leaf. Hence n≤3^k and at least ⌈log₃ n⌉ weighings are required in the worst case.
For n=3^k, divide the candidates into three equal piles and weigh two piles against each other. If one pan is heavier, the coin is in that pile because all other coins on both pans have the same mass. A balance puts the heavier coin in the unweighed pile.
Repeat on the identified third. Each weighing reduces the number of candidates by a factor of three, so after k weighings exactly one remains. For n=1 no weighing is needed, which agrees with the bound. See [Outcome trees count distinguishable answers](https://ocw.mit.edu/courses/6-006-introduction-to-algorithms-fall-2011/bf7d79105762bf79bbc0925438e1468a_MIT6_006F11_lec07.pdf#page=2). At most three outcomes per weighing give the leaf bound. The exact repeated three-way split applies when the starting population is a power of three.
Find the largest amount two coprime stamps cannot make
Since a,b are coprime, the numbers kb for k=0,1,…,a−1 give every residue modulo a exactly once. For an integer N choose k in this range such that N−kb is divisible by a.
If N>ab−a−b, then N−kb≥ab−a−b+1−(a−1)b=1−a. A multiple of a that is at least 1−a must be nonnegative.
Therefore N−kb=ja for some j≥0, and N=ja+kb is a permitted combination. This proves that every larger integer can be made.
For N₀=ab−a−b=(a−1)b−a, any representation N₀=ja+kb would require k≡a−1 modulo a. A nonnegative k with that residue is at least a−1, so N₀−kb≤−a. This rules out j≥0 and establishes the largest missing value. See [Find the greatest common measure](https://mathcs.clarku.edu/~djoyce/java/elements/bookVII/propVII2.html). Coprimality makes the multiples of b a complete residue list modulo a. The lesson proves the exact largest missing value with nonnegative coefficients.
Prove the pattern of a bounded subtraction game
The empty pile is losing because its player cannot move. A move from any positive multiple of m+1 removes a number between one and m, so it leads to a count that is not a multiple of m+1.
From any other positive count N, the remainder r on division by m+1 satisfies 1≤r≤m and r≤N. Removing exactly r takes the pile to a multiple of m+1.
Every move decreases the number of tokens, so induction on N proves the losing classification. A multiple can move only to winning positions, and any other positive count has a move to a losing position.
After a move to a positive multiple, an opponent’s removal s can be answered by removing m+1−s. That brings the next total to another multiple. Both removals are legal while there is such a turn, and this pairwise play ends at zero. See [Normal play and least-missing game values](https://fanchung.ucsd.edu/152/fergusonI.pdf). For this specific bounded subtraction rule, the modular remainder supplies one move to a losing state. Normal play fixes the empty state as losing.
Find and preserve zero xor in Nim
Let S be the bitwise xor of the heap counts. Replacing a heap a by b changes the total to S xor a xor b. From S=0 any legal change has a≠b, so the new total is nonzero.
When S≠0, let r be the index of its highest one bit. At least one heap a has a one in that bit because the xor bit is one. Put b=a xor S.
All bits above r remain unchanged and the bit at r changes from one to zero. Therefore b<a and the move is legal. Its new total is S xor a xor (a xor S)=0.
From a nonzero xor, a heap with the highest set xor bit can be reduced to eliminate the entire xor. Starting at xor zero, changing just one heap changes the xor away from zero.
| Quantity | Exact result |
|---|---|
| Xor | 2 |
| Zero-xor reductions | 0→1 |
| Legal moves exist | True |
| Winning under normal play | True |
| Candidate new heap values | 3→1 is a reduction; 4→6 and 5→7 increase their heaps. |
Exact inputs and supporting calculations
| Parameter | Value |
|---|---|
| heaps | [3,4,5] |
The game ends because the total heap size strictly decreases. The terminal position has xor zero. The two move properties therefore prove by induction that zero-xor positions are losing and all other positions have a winning move. See [Winning and losing Nim positions](https://paradise.caltech.edu/ist4/lectures/Bouton1901.pdf). The highest changed bit selects a heap that can legally be reduced to the value required for zero xor. Each move acts on one heap.
Assign values to finite impartial game states
For a finite acyclic game, define g(s) from terminal states backward as the least nonnegative value missing from its successors’ values. Terminal states have value zero. Every smaller value than g(s) occurs among successors, and g(s) itself never occurs there.
For a position combining several games, form S as the xor of their g-values. A move changes one component to a successor with a different value. Thus if S=0 every legal move makes it nonzero.
If S≠0, choose a component whose value a has a one in the highest nonzero bit of S. The value b=a xor S is smaller than a. The definition by the least missing value ensures at least one available successor with value b.
Moving that component makes the new xor zero. Every move in a component strictly decreases the maximum length of a directed path starting at its current position. The sum of these finite maxima decreases on every move, so the combined game terminates. With xor zero at terminal states the two move properties prove the losing and winning criteria. See [Normal play and least-missing game values](https://fanchung.ucsd.edu/152/fergusonI.pdf). The least excluded value supplies the reachable smaller values. The proof uses the sum of maximum directed path lengths to establish termination.
Solve a lights puzzle by adding moves modulo two
Represent the light state by a vector of bits. For each switch, let its flip pattern be a column t_j with a one wherever that switch toggles the light. A press adds t_j modulo two.
Two presses of the same switch add zero because t_j+t_j=0 in this arithmetic. Addition of the columns commutes, so the resulting change depends only on the vector x of odd press counts.
With T containing these columns, the state b reaches a desired state h exactly when Tx=h−b over the two-element field. Each binary solution is realized by pressing each selected switch once, which proves sufficiency as well.
This finite matrix equation is verified by trying every press vector. A minimum-weight solution is shortest under equal costs and repeating a switch twice can be omitted.
| Quantity | Exact result |
|---|---|
| Solutions | 01 |
| Minimum press count | 1 |
| All minimum solutions | 01 |
Exact inputs and supporting calculations
| Parameter | Value |
|---|---|
| M | [[1,1],[0,1]] |
| b | [1,1] |
If x₀ is one solution and z satisfies Tz=0, then x₀+z is another. Conversely the difference of two solutions lies in the null space. Thus the set of possible press patterns, when nonempty, is one solution plus all null vectors. See [Light switches as linear combinations modulo two](https://people.sc.fsu.edu/~jburkardt/classes/imps_2017/11_28/2690705.pdf). Each odd press count contributes a fixed column. Solvability is membership in that column space, and differences of solutions lie in its null space.
Find shortest puzzle solutions by layers
Let L₀ consist of the starting state. From each vertex in L_k consider all outgoing legal edges. Put their endpoints into L_(k+1) only if the endpoint has not appeared in any earlier layer.
Inductively every state in L_k can be reached in k moves, so each added endpoint has a legal path of length k+1. If it had a shorter path it would already appear in a previous layer.
Conversely, a shortest path of length k+1 has a predecessor of minimum distance k. Any shorter path to that predecessor would shorten the last path as well. Induction puts the predecessor in L_k and then puts the endpoint in the next layer.
In a finite graph the exploration ends when a layer adds no new state. Every reachable state has a finite shortest path, so that exhaustion certifies all reachable states were found. The layer index is a minimum move count because every edge costs one move. See [Shortest paths by breadth-first layers](https://ocw.mit.edu/courses/6-006-introduction-to-algorithms-spring-2020/6afd7e9a85d7d36e204533569f9fccf6_MIT6_006S20_r09.pdf#page=3). The level of first discovery gives the least number of moves when every move has unit cost. Predecessors recover the exact legal route.
Prove the least move count for Tower of Hanoi
Let T(n) be the least number of moves between two distinct pegs starting with a legal stack of n discs. By symmetry this depends only on n. For n=0 no move is needed.
To build a transfer, move the top n−1 discs onto the spare peg, move the largest disc to the destination, and move the smaller stack from the spare onto it. This gives T(n)≤2T(n−1)+1.
For any legal solution, immediately before the first largest-disc move all smaller discs must be stacked on the one peg used by neither end of that move. The moves of the smaller discs to that peg require at least T(n−1).
Immediately after the last move of the largest disc into the destination, the smaller discs are all on the third peg of that move. Their remaining transfer again needs at least T(n−1). These two portions are disjoint and at least one largest move lies between them, so T(n)=2T(n−1)+1. With T(0)=0 this solves to 2^n−1. See [Construct and bound an ordered disk transfer](https://www.ocw.mit.edu/courses/6-042j-mathematics-for-computer-science-spring-2015/mit6_042js15_textbook2.pdf#page=650). The largest disk forces smaller-stack transfers on both sides of its moves. The direct transfer gives the matching recursive construction.
Characterize one-stroke drawings
In a trail that uses each edge once, every arrival at an internal appearance of a vertex is paired with a departure. Thus all degree contributions are even except possibly at the two endpoints. A closed trail pairs all contributions.
Suppose all degrees are even. Follow unused edges from a vertex with an incident edge until no continuation is available. At a current endpoint distinct from the start, the unpaired arrival would leave an unused incident edge, by even degree. So the resulting trail closes.
If edges remain, connectivity of the nonisolated part gives a vertex of the existing trail incident to an unused edge. In the unused graph all degrees are still even, because the closed trail used an even number at each vertex. Start a new closed trail there and insert it into the earlier one. Repeat until all edges are used.
If there are exactly two odd-degree vertices, temporarily add an edge between them, allowing a parallel edge if needed. The degrees become even and a closed all-edge trail exists. Cutting it at the added edge and deleting that edge leaves the desired trail from one original odd vertex to the other. See [The degree obstruction in a bridge walk](https://la.wikisource.org/wiki/Solutio_problematis_ad_geometriam_situs_pertinentis). Interior edge pairings give the degree condition. The proof fills in a modern cycle-splicing construction for the connected edge-bearing portion.
Find a same-color triangle among six vertices
Choose one of the six vertices and consider its five incident edges. At least three have the same color by the pigeonhole principle. Suppose that color is red and name their other endpoints a,b,c.
If any edge among a,b,c is red it forms a red triangle with the chosen vertex. If none is red, then the three edges among a,b,c are blue, producing a blue triangle. The same reasoning applies when the incident color is blue.
For five vertices, color the edges of a five-cycle red and all remaining edges blue. The red cycle has no three-cycle.
The blue edges are the step-two edges along the same circular order. They form another five-cycle, since starting at a vertex and advancing by two passes through all five. The blue graph also has no triangle, so five vertices do not force a single-color triangle. See [A forced monochromatic triangle](https://math.mit.edu/~apost/courses/18.204_2018/ramsey-numbers.pdf). Among five incident edges, three share a color. The triangle on their other endpoints either has an edge of that color or is entirely in the other color.
Derive the center of a three-by-three magic square
The numbers one through nine sum to forty-five. The three row sums are equal, so each must be fifteen. The same common sum applies to columns and both diagonals by the definition of the puzzle.
Write c for the center. Add the four line sums through it, namely the middle row, middle column and both diagonals. Every noncentral entry occurs once and the center occurs four times.
The total of those sums is 60, and the entries account for it as 45+3c. Solving gives c=5. Each pair of opposite entries on a line through it then sums to ten.
For example use the rows (6,7,2), (1,5,9), and (8,3,4). They contain one through nine once each, and the row sums, column sums and the two diagonal sums are all fifteen. Thus the required center and line sums can occur together. See [The center of a three-by-three magic square](https://www.math.kent.edu/~white/MIMEalgebra/magicsq-proof2.pdf). The nine fixed entries total forty-five. The four center lines count the center three extra times and force it to have value five.
Construct orthogonal Latin squares using residues
Use rows and columns indexed by residues i,j modulo odd n. In the first array i+j, either index fixed gives addition of a constant to the other. This permutes all residues.
In the second array i+2j, fixing j gives a translation of i. Fixing i gives multiplication of j by two followed by a translation. Since n is odd, two is invertible modulo n, so each row again gives all residues.
For a desired pair (u,v), solve i+j=u and i+2j=v. Subtracting gives j=v−u and then i=2u−v. Those residues are unique and direct substitution verifies both values.
Thus both arrays are Latin and their superposition has every pair once. The orthogonality equation itself can be solved by subtraction for any n. Oddness is the extra condition making each row of the second array a permutation. See [Orthogonal residue-square constructions](https://strickland1.org/courses/MPS352/notes_html/S14.html). The prime field construction motivates the pair of modular arrays. For the chosen slopes, oddness supplies exactly the needed inverse of two.
Count matching triples of three-valued feature cards
Encode the three possible values of each coordinate by 0,1,2 modulo three. If all three coordinate entries are equal, their sum is zero modulo three. If all are different, their sum is 0+1+2, also zero.
If exactly two entries equal a and the third is b≠a, then 2a+b is congruent to b−a, which is nonzero. So three feature vectors x,y,z obey the card condition precisely when x+y+z=0 in every coordinate.
For distinct x,y, the unique possible third vector is z=−x−y. If it equalled x, then y=−2x=x modulo three. This is a contradiction, and the same argument excludes equality with y.
With N=3^d card vectors there are N(N−1)/2 unordered pairs. Each produces one triple, and each triple contains exactly three of those pairs, all yielding that same triple. Hence there are N(N−1)/6 unordered matching triples. See [Feature triples and points over the field of three elements](https://lsgm.uni-leipzig.de/lsgm/Bibliothek/Davis_Maclagan-CardGameSet.pdf). The coordinate equation over the field of three elements provides a unique completion of each distinct pair. Each triple is counted three times.
Force two disjoint selections to have equal sums
Index the n positive integers, so two positions remain distinct even if their values agree. There are 2^n subsets of the index set, and a subset sum is an integer from zero through S.
If 2^n>S+1, two distinct subsets U,V must have equal sums because there are at most S+1 different totals. This follows by assigning each subset to the box named by its sum.
Remove all shared indices from the two subsets. The total removed is the same on each side, so the remaining two selections still have equal sums. They are disjoint by construction.
Since the original subsets differ, at least one remaining selection is nonempty. Its sum is positive. The other must have that same positive sum and also be nonempty, completing the disjoint construction. See [Subset-sum collisions by pigeonhole](https://www.ocw.mit.edu/courses/6-042j-mathematics-for-computer-science-spring-2015/mit6_042js15_textbook2.pdf#page=582). The finite sum map must have a collision once there are more subsets than possible totals. Positivity makes the disjoint residual sets nonempty.
Count a fixed-step orbit on a circle
Work modulo n with starting label s and step k. After t steps the label is s+tk modulo n, so the first return is the least positive t for which n divides tk.
Write g=gcd(n,k), n=gn′ and k=gk′. Because n′ and k′ are coprime, n divides tk exactly when n′ divides t. The first return is therefore at t=n′.
The labels in the first n′ steps before the return are distinct, because equality of two of them would give a smaller positive return. Each differs from s by a multiple of g.
There are exactly n′ residues modulo n congruent to s modulo g. Thus the orbit contains that entire congruence class. It covers all labels precisely when g=1. If k=0 then g=n and the orbit consists of just s. See [Find the greatest common measure](https://mathcs.clarku.edu/~djoyce/java/elements/bookVII/propVII2.html). Cancel the common divisor from the return divisibility. The resulting period visits exactly the stated residue class, including the fixed zero-step case.
Guarantee guesses by one parity announcement
Number the players in speaking order, with player one at the back and able to see hats two through n. Agree to encode the colors as bits zero and one.
Player one announces the xor of the hats ahead. This announcement uses one of the permitted color words and may or may not match player one’s own hat.
At player k≥2, the visible hats are k+1 through n. The earlier correct guesses of players two through k−1 give their hats. Xor these visible and already inferred bits with the original announcement. Every known bit cancels twice, leaving player k’s actual bit.
Player two needs no earlier correct guess beyond the first announcement, so the argument starts there. Induction gives correctness for every later player. The guarantee holds for every hat assignment under the declared speaking and visibility rules. See [Light switches as linear combinations modulo two](https://people.sc.fsu.edu/~jburkardt/classes/imps_2017/11_28/2690705.pdf). Addition modulo two makes each known bit cancel when used twice. The declared visibility and speaking order make the induction possible.
Turn an alphametic into digit constraints
The place-value expressions are AB=10A+B and BA=10B+A, where A and B are decimal digits from one to nine. Adding gives 11(A+B).
The required total 121 is 11·11, so the digit condition is precisely A+B=11. A must be at least two, since A=1 would make B=10. Every A from two through nine gives an allowed B=11−A.
The sum eleven is odd, so the two digits cannot be equal. Each of the eight choices of A therefore gives a valid ordered pair. The reversed order gives another of those pairs.
The four unordered pairs are {2,9}, {3,8}, {4,7} and {5,6}. Directly each gives 121 because the units contribute eleven, carrying one into the tens, and the same digit sum applies again at that place. See [Decimal places and expanded form](https://openstax.org/books/contemporary-mathematics/pages/4-1-hindu-arabic-positional-system). The two place expansions turn the reversed sum into a multiple of eleven. The nonzero digit bounds and exact sum enumerate the valid pairs.
Bound the number of binary questions
An adaptive yes-or-no procedure with worst-case length k gives a binary tree of depth at most k. A leaf records a sequence of answers that identifies a single remaining possibility.
Such a tree has at most 2^k leaves. One can see this by induction on depth, since each of the at most two subtrees has depth at most k−1. Thus n≤2^k is necessary and k≥⌈log₂ n⌉.
For an attaining strategy, set k=⌈log₂ n⌉ and assign distinct length-k bit strings to the possibilities. At each of k questions ask whether that position’s bit equals one. Each question is a permitted split of the remaining set.
At depth q a binary tree has at most 2^q leaves. Balanced splits attain sufficient worst-case depth, though a specific target can land at a shorter leaf.
| Quantity | Exact result |
|---|---|
| Answers | False, False, False |
| Path length | 3 |
| Worst-case lower bound | 3 |
| Recovered label | 4 |
Exact inputs and supporting calculations
| Parameter | Value |
|---|---|
| M | 5 |
| z | 4 |
The answers recover one full label, which identifies exactly one possibility. If n=1 then the sole label has length zero and no question is needed. The strategy therefore meets the lower bound for every n≥1. See [Outcome trees count distinguishable answers](https://ocw.mit.edu/courses/6-006-introduction-to-algorithms-fall-2011/bf7d79105762bf79bbc0925438e1468a_MIT6_006F11_lec07.pdf#page=2). Distinct answers need distinct leaves in a binary question tree. A labeling construction attains the bound if questions about arbitrary subsets are allowed.
Compute switching odds under a precise host rule
Fix the first choice as A and call the other doors B and C. Staying succeeds precisely when the uniform prize is at A, so its probability is one third. Switching succeeds precisely when the initial choice misses, because the host can open only the other goat and leaves the prize closed.
For an observed opening of C, record its chance for each prize placement. With a prize at A, two unchosen goats are available so the chance is one half. With a prize at B, C must open. With a prize at C, it cannot open.
The corresponding joint probabilities for a prize at A, B or C and an opening of C are one sixth, one third and zero. The opening of C therefore has probability one half. Dividing by this probability leaves conditional prize probabilities one third at A and two thirds at B.
The calculation for a particular opening uses the stated tie rule. Swapping the names of the two unchosen doors gives the same conditional odds when B opens. The overall success probability of the always-switch policy already follows from whether the first choice was wrong. See [Switching under specified host behavior](https://pub.math.leidenuniv.nl/~gillrd/essential_MHP.pdf). The logical complement gives the total switch win rate. The stated tie rule separately gives the likelihood for a specific open door.
Count the chance of a repeated label
Put the n choices in order. For n≤m, when the first j choices have all differed, exactly m−j labels are available for the next choice without a repetition. Uniformity gives conditional probability (m−j)/m, and the independence of draws leaves this value unchanged by the particular preceding labels.
Multiplying these conditional probabilities gives the probability of no match as ∏ from j=0 to n−1 of (1−j/m). The probability of at least one match is one minus this product. For n>m, the pigeonhole principle makes a match certain.
For a specified pair of distinct draws, the second label equals the first with probability 1/m. The event that some pair agrees is a union of n(n−1)/2 events of this type. The union bound gives probability at most the smaller of one and n(n−1)/(2m).
The pair events need no mutual independence for the upper bound. The assumed sampling law supplies their individual probabilities and the successive conditional factors for the exact calculation. With zero or one draw there are no pairs and the match probability is zero. See [Count collision probabilities by counting the complement](https://web.mit.edu/broder/Public/6.042-lecture-notes/lec21.pdf#page=11), [The empty product acts as the multiplicative identity](https://www.ocw.mit.edu/courses/6-042j-mathematics-for-computer-science-spring-2015/mit6_042js15_textbook2.pdf#page=624). Independent uniform draws determine the distinct-choice product. Pairwise events require no mutual independence for the union upper bound.
Find waiting times for overlapping toss patterns
For each pattern, start from a state with no usable final H or with a final H available to begin the next matching attempt. In disjoint blocks of two fair tosses, the probability that a specified block matches the chosen pattern is one quarter. Independence across blocks bounds the waiting tail geometrically, so the relevant expectations are finite.
Write E₀ for the mean additional time without a usable H and E_H for the mean after a usable final H. From the first state, tails leave it unchanged and heads move it to the second state, so E₀=1+(E₀+E_H)/2, or E₀=2+E_H.
For HH, a new head completes the pattern and a new tail leaves no usable H. Hence E_H=1+E₀/2. Substitution into E₀=2+E_H gives E₀=3+E₀/2 and therefore E₀=6.
For HT, a new tail completes the pattern, while a new head leaves a final H ready for another attempt. Now E_H=1+E_H/2=2, and E₀=4. The two patterns have the same chance in a specified pair of tosses and different continuation behavior after a failed second letter. See [Pattern waiting times by first-step recurrences](https://data140.org/sp17/textbook/ch13/Waiting_Till_a_Pattern_Appears.html). A usable final H is the relevant state. The two patterns have different continuation after a failed second symbol, and a geometric block bound justifies finite means.
Find which absorbing endpoint a fair token walk reaches
Assume N≥1, with a fair independent choice of step direction at each turn before absorption. A run of N consecutive positive steps forces a token from any interior state to reach N. We may preassign an infinite sequence of directions so the event of all positive directions in any fixed block is defined even on paths absorbed earlier.
Each block of N directions has probability 2⁻ᴺ of being all positive. If the token has survived k full blocks, none of those blocks was all positive, so this survival probability is at most (1−2⁻ᴺ)ᵏ. Its limit is zero.
Let uᵢ be the probability of reaching N before zero from i. Immediate absorption gives u₀=0 and u_N=1. At any interior state first-step conditioning gives 2uᵢ=uᵢ₋₁+uᵢ₊₁, which rearranges to uᵢ₊₁−uᵢ=uᵢ−uᵢ₋₁.
The harmonic probability averages its neighbors. Expected time adds one before averaging. The exact solutions are s/N and s(N−s), respectively.
| Quantity | Exact result |
|---|---|
| Right-hit probability | 2/5 |
| Expected number of steps | 6 |
| Boundary probabilities | (0, 1) |
| Boundary times | (0, 0) |
Exact inputs and supporting calculations
| Parameter | Value |
|---|---|
| N | 5 |
| s | 2 |
All N increments between consecutive states are equal and sum to one. Each is therefore 1/N, and uᵢ=i/N. This value also covers N=1, when both states are endpoints and no recurrence is needed. See [Absorbing endpoint odds by a difference equation](https://faculty.washington.edu/yenchic/26A_stat516/Lec3_DTMC_p1.html). The absorbing endpoints and the first-step recursion determine a linear solution in the fair case. An independent block argument supplies almost-sure absorption.
Split a fair game interrupted before either player wins
Write h=r+s−1 and imagine h independent fair outcomes, including a continuation of the outcome list after the game stops. Within these h rounds the first player can reach r wins or the second can reach s. If neither reaches the threshold, their combined wins total at most r+s−2.
Both thresholds cannot be reached within the h outcomes because that would require at least r+s rounds. The single threshold reached by the end of the extended list identifies the winner in the original rule. The first player therefore wins exactly when the list contains at least r first-player wins.
For each possible count k, there are binomial(h,k) lists with k first-player wins, out of 2ʰ equally probable lists. Sum those counts for k from r through h and divide by 2ʰ. For r=1 and s=2 the three lists other than two second-player wins give probability three quarters.
For a fixed classroom prize and equal linear value of each share, the conditional expected prize shares are this probability and its complement. The calculation assumes the future rounds are independent and fair and the quotas depend only on the existing score. Changed round odds need a different outcome law. See [Complete a two-player interrupted game to a fixed horizon](https://sidoli.w.waseda.jp/Pascal_Fermat_correspondence_1654.pdf), [Counting fixed numbers of positions](https://www.ocw.mit.edu/courses/6-042j-mathematics-for-computer-science-spring-2015/mit6_042js15_textbook2.pdf#page=573). The fixed horizon forces exactly one player to reach the required count, and a binomial count gives the first player’s probability.
Use nontransitive dice to test pairwise order
Use fair dice with faces A=(4,4,4,4,0,0), B=(3,3,3,3,3,3), C=(6,6,2,2,2,2) and D=(5,5,5,1,1,1). Compare independently sampled faces. The listed adjacent comparisons have no tied outcomes.
A beats B exactly on its four faces labeled four, giving probability 4/6. B beats C exactly when C shows two, also with probability 4/6.
C beats D whenever C shows six, with probability 1/3, and when C shows two while D shows one, with probability (2/3)(1/2). These disjoint ways total 2/3.
D beats A whenever D shows five, with probability 1/2, and when D shows one while A shows zero, with probability (1/2)(1/3). The total is 2/3, closing the cycle A over B over C over D over A under this pairwise preference rule. See [Pairwise dice comparisons and cycles](https://www.mit.edu/~asah/papers/2302.11293.pdf). The paired-face comparison defines each result. The four displayed pairwise probabilities form a directed cycle under independent rolls.
Count cyclic arrangements using fixed points
Let a finite group G act on a finite set X. Count ordered pairs (g,x) with g·x=x. Grouping by g gives the sum of the number of objects fixed by each group element. Grouping by x gives the sum of the sizes of their stabilizers.
For any x in an orbit O, every y in O is reached by the same number of group elements. If g₀ sends x to y, the elements sending x to y are precisely g₀h for h fixing x. The fiber has size |Stab(x)| and there are |O| fibers.
It follows that |Stab(x)|=|G|/|O| for every x in O. The contribution of all x in one orbit is |G|. Dividing the fixed-point sum by |G| therefore gives the number of orbits.
For binary words of length three the identity rotation fixes all eight words. Each of the other two rotations cycles all three positions and fixes only the two constant words. The average (8+2+2)/3=4 counts length-three binary necklaces up to rotation. See [Fixed objects and orbit counts](https://users.math.msu.edu/users/bsagan/Books/Aoc/GSM210.pdf#page=209). Count pairs of a group element and an object fixed by it. Orbit and stabilizer sizes convert the total into an average over rotations.
Construct a cycle containing all short binary words
Use all binary words of length n−1 as vertices. For each length-n binary word draw one directed edge from its initial n−1 letters to its final n−1 letters. Each vertex has two outgoing edges by appending either bit and two incoming edges by prepending either bit.
Successively appending the bits of a target vertex gives a directed walk to that vertex from any starting vertex. The directed graph is thus strongly connected. Follow unused outgoing edges from any start until unable to continue. Balance at a different current vertex would supply an outgoing edge, since the walk has used one extra incoming edge there.
The first such trail closes at its starting point. Removing a closed trail preserves balance. If edges remain unused, connectivity supplies an unused outgoing edge at a vertex on the current circuit. In fact, a directed route to any still-unvisited vertex must leave the visited set on an unused edge, and an unused edge with visited tail already qualifies. Construct and splice a further closed trail there until every edge is used.
Record the bit appended by each edge, in cyclic order along the resulting circuit. The vertex just before an edge consists of the preceding n−1 appended bits, as can be seen by traversing the circuit cyclically for those n−1 steps. Thus the n-bit block ending at the new bit is precisely that edge label. Every length-n binary word occurs once. See [Binary windows from complete directed walks](https://pure.tue.nl/ws/portalfiles/portal/4442708/597473.pdf), [The degree obstruction in a bridge walk](https://la.wikisource.org/wiki/Solutio_problematis_ad_geometriam_situs_pertinentis). Binary overlap labels give the directed circuit model. Equal incoming and outgoing degrees and reachability justify traversing every edge exactly once.
Count lattice routes that avoid one vertex
A shortest east-and-north route to (a,b) consists of a east steps and b north steps. Selecting the a positions for the east steps specifies the route, so there are binomial(a+b,a) routes in total.
Let (c,d) be the specified interior vertex, with 0<c<a and 0<d<b. A route passing through it has a unique prefix with c east and d north steps and a suffix with a−c east and b−d north steps. A monotone route cannot visit the vertex twice.
Conversely any such prefix and suffix concatenate to a legal route through the vertex. There are binomial(c+d,c) possible prefixes and binomial(a+b−c−d,a−c) suffixes, so multiply their counts.
To count the avoiding routes, subtract this product from binomial(a+b,a). The bijection uses a single forbidden vertex and the fixed set of shortest steps. For multiple forbidden vertices the sets of routes through them may intersect. See [Counting fixed numbers of positions](https://www.ocw.mit.edu/courses/6-042j-mathematics-for-computer-science-spring-2015/mit6_042js15_textbook2.pdf#page=573). Choose fixed north-step slots to count paths. Routes through an interior vertex split uniquely, so the prefix and suffix counts multiply.
Partition the positive integers with two irrational floor sequences
For an integer m≥0, the number of terms ⌊nα⌋ with n≥1 and ⌊nα⌋≤m equals the count of positive integers n with n<(m+1)/α. The right-hand side is nonintegral because α is irrational. Thus the count equals ⌊(m+1)/α⌋, and the same reasoning holds for β.
The two quotients add to m+1 by the reciprocal condition. Both are nonintegers, so the sum of their fractional parts is an integer strictly between zero and two. It equals one, and the sum of the two floors is m.
Counting both sequences with multiplicity gives m entries at most m and m−1 entries at most m−1 for m≥1. Exactly one entry equals m, which proves both coverage and uniqueness. The assumption α,β>1 ensures positive, increasing floor sequences.
For φ=(1+√5)/2 we have φ²=φ+1. Therefore φ and φ² are irrational and both exceed one, and (φ+1)/φ²=1 is precisely 1/φ+1/φ²=1. Their floor sequences satisfy the claimed partition. See [Two complementary irrational floor sequences](https://mddcvasection.org/MeetingFiles/Spring2016Meeting/TalkSlides/Brown.pdf#page=5). The two nonintegral counting quotients add to a specified integer. Their floors count exactly one new term at each positive integer.
Find a shortest route touching a given line
Let P and Q lie on the same open side of a line, and let P′ be the reflection of P across it. For each contact X on that line the reflection fixes X and preserves distance, giving |PX|=|P′X|.
The total length through X is therefore |P′X|+|XQ|, which is bounded below by |P′Q| by the triangle inequality. Equality occurs precisely when X lies on the straight segment from P′ to Q.
Since P′ and Q lie in opposite open half-planes, the segment crosses the line once. This intersection is the unique contact attaining the lower bound and so solves the unrestricted line problem.
For a nonempty closed allowed segment on the line, the same contact and value apply exactly when that segment contains the intersection. If it omits the intersection, continuity on the allowed compact segment still gives a minimum and every admissible contact has length strictly greater than |P′Q|. See [Length comparison in a triangle](https://mathcs.clarku.edu/~djoyce/java/elements/bookI/propI20.html). Reflection makes the two route pieces a broken line between fixed endpoints. Equality in the length bound identifies the unique contact.
Invent a winning family of mirror-position puzzles
Index the path by the integers −m through m. Mark zero first, which is legal and leaves a marked set symmetric under i↦−i. The center and any positions adjacent to it cannot be used by the opponent.
Suppose the set of marked positions is symmetric before the opponent marks a legal i. Before this move, −i is unmarked and has no marked neighbor by symmetry. The two positions are distinct, and |i|≥2, so the mark at i adds no adjacent mark to −i.
The first player can therefore reply by marking −i. The two new marks restore symmetry, so the same rule applies after any subsequent legal move by the second player. The rule also covers the case in which there is no opposing move after the initial mark.
Every move marks a new position, and the board has finitely many positions. As long as the second player has a legal move, the first player has a legal reply. Normal play leaves the second player without a move at the end. See [Normal play and least-missing game values](https://fanchung.ucsd.edu/152/fergusonI.pdf). In this finite normal-play family the center mark leaves reflection symmetry. After any legal opposing choice the reflected mark is legal and restores it.
Trace exact puzzle moves, invariants and decision paths to learn what each proof certifies.
Check digits and retain leading zeros
Distinct endpoints: 321
The absolute difference equals 99 times the positive difference between endpoint digits. For distinct endpoints its padded reverse produces the complementary digit pattern and the sum 1089. Equal endpoints give difference zero.
| Quantity | Exact result |
|---|---|
| Original | 321 |
| Reversed | 123 |
| Difference | 198 |
| Reversed difference | 891 |
| Endpoint digits differ | True |
| Sum | 1089 |
Exact inputs and supporting calculations
| Parameter | Value |
|---|---|
| x | 321 |
Compare a gcd obstruction with a reachable jug state
Three- and five-unit jugs reach four
The operations preserve multiples of the capacity gcd. Breadth-first discovery assigns the smallest number of unit-cost moves to each visited state.
| Quantity | Exact result |
|---|---|
| gcd | 1 |
| Reachable states | 16 |
| Target reached | True |
| Shortest actions | 6 |
| Path | (0, 0) → (0, 5) → (3, 2) → (0, 2) → (2, 0) → (2, 5) → (3, 4) |
Exact inputs and supporting calculations
| Parameter | Value |
|---|---|
| a | 3 |
| b | 5 |
| target | 4 |
| State | Distance |
|---|---|
| (0, 0) | 0 |
| (3, 0) | 1 |
| (0, 5) | 1 |
| (3, 5) | 2 |
| (0, 3) | 2 |
| (3, 2) | 2 |
| (3, 3) | 3 |
| (0, 2) | 3 |
| (1, 5) | 4 |
| (2, 0) | 4 |
| (1, 0) | 5 |
| (2, 5) | 5 |
| (0, 1) | 6 |
| (3, 4) | 6 |
| (3, 1) | 7 |
| (0, 4) | 7 |
Move exactly one heap to force xor zero
A single forced zero-xor reduction
From a nonzero xor, a heap with the highest set xor bit can be reduced to eliminate the entire xor. Starting at xor zero, changing just one heap changes the xor away from zero.
| Quantity | Exact result |
|---|---|
| Xor | 2 |
| Zero-xor reductions | 0→1 |
| Legal moves exist | True |
| Winning under normal play | True |
| Candidate new heap values | 3→1 is a reduction; 4→6 and 5→7 increase their heaps. |
Exact inputs and supporting calculations
| Parameter | Value |
|---|---|
| heaps | [3,4,5] |
Solve a finite toggle system over F₂
Invertible toggle system gives one solution
This finite matrix equation is verified by trying every press vector. A minimum-weight solution is shortest under equal costs and repeating a switch twice can be omitted.
| Quantity | Exact result |
|---|---|
| Solutions | 01 |
| Minimum press count | 1 |
| All minimum solutions | 01 |
Exact inputs and supporting calculations
| Parameter | Value |
|---|---|
| M | [[1,1],[0,1]] |
| b | [1,1] |
Use a balanced decision tree with stable labels
Five labels and a short path to label 4
At depth q a binary tree has at most 2^q leaves. Balanced splits attain sufficient worst-case depth, though a specific target can land at a shorter leaf.
| Quantity | Exact result |
|---|---|
| Answers | False, False, False |
| Path length | 3 |
| Worst-case lower bound | 3 |
| Recovered label | 4 |
Exact inputs and supporting calculations
| Parameter | Value |
|---|---|
| M | 5 |
| z | 4 |
Find the probability of the right absorbing endpoint
Interior start at position two
The harmonic probability averages its neighbors. Expected time adds one before averaging. The exact solutions are s/N and s(N−s), respectively.
| Quantity | Exact result |
|---|---|
| Right-hit probability | 2/5 |
| Expected number of steps | 6 |
| Boundary probabilities | (0, 1) |
| Boundary times | (0, 0) |
Exact inputs and supporting calculations
| Parameter | Value |
|---|---|
| N | 5 |
| s | 2 |
Worked examples
Check a missing-corner chessboard
From an eight-by-eight chessboard remove two opposite corners. Count the remaining cells in each color and decide whether dominoes can tile it.
- On the full board the two colors alternate along each row, with four of each in every row. Across eight rows that gives thirty-two of each color. The corner coordinates can be taken as (1,1) and (8,8), with even coordinate sums at both.
- Removing the two corners deletes two cells of the same color. There are now thirty cells of that color and thirty-two of the other. There are sixty-two cells altogether, enough in area for thirty-one dominoes.
- Each domino would cover neighboring cells of opposite colors. Thirty-one dominoes would therefore each account for one square of each color, requiring thirty-one cells of each color.
- The remaining color counts contradict this necessary condition. The tiling is impossible even though the remaining area is a multiple of two.
Thirty of one color and thirty-two of the other remain. Dominoes cannot tile the board.
Compute a digit reversal puzzle
Apply the three-place subtraction and reversal procedure to 421. Show the original reversal, difference and final sum.
- Reverse the original three-place numeral 421 to obtain 124. As 421 is larger, subtract 124 from 421.
- The difference is 297. Its three places read backwards are 792. Both are already written with three digits in this example.
- Add to get 297+792=1089. In the units place 7+2=9, and 9+9=18 in the tens place leaves eight with a carry.
- In the hundreds place 2+7+1=10 so the final carry produces the leading one. The original hundreds and units digits differ by three, consistent with the difference 3·99=297.
The reversal is 124, the difference is 297, and 297+792=1089.
Apply the sliding-tile invariant
From the solved four-by-four sliding puzzle with the blank at bottom right, exchange only tiles fourteen and fifteen. Decide if legal blank moves reach this position from the solved one.
- In row-by-row order, ignoring the blank, the solved tile list is increasing. Its inversion count is zero, and the blank is in row one when counted upward from the bottom.
- In the proposed position only the consecutive labels fourteen and fifteen have exchanged places. This adds one inversion and changes no comparison with the other labels. The blank is still in row one from the bottom.
- The parity of inversions plus the blank row is odd in the solved position and even in the exchanged position. A horizontal slide changes neither parity. A vertical slide on width four passes three listed tiles and moves the blank by one row, flipping both parities.
- Their sum has the same parity throughout every legal play from the solved configuration. Because the exchange has the other parity, no legal sequence reaches it.
The proposed exchange is unreachable. Inversions plus the blank's bottom-counted row changes parity.
Measure four units with two jugs
Use jugs of capacities three and five to reach four units in the five-unit jug. Give a full legal sequence and check the final pour.
- Write (a,b) for the amounts in the three- and five-unit jugs. Begin at (0,0), fill the small jug to (3,0), and pour it into the large jug until the small jug empties to reach (0,3).
- Refill the small jug to reach (3,3). Pour until the large jug becomes full, transferring two units to reach (1,5). Empty the large jug to obtain (1,0) and pour in the remaining one to make (0,1).
- Fill the small jug again to get (3,1). Its three units fit within the four available spaces in the large jug, so a full pour leaves (0,4).
- The last pour stops because the source is empty. Each fill, pour or emptying used only the allowed endpoint rule, and the destination contains four units.
The stated legal sequence ends at (0,4), with four units in the five-unit jug.
Compare two torch-crossing plans
For people with times 1,2,7,10, compare sending the two slowest together with the two fastest making the separate returns, and having the fastest escort each other person separately. Give both legal sequences and elapsed times.
- Call the people A, B, C and D with times 1, 2, 7 and 10. The torch starts on their side and accompanies one or two people on every crossing. A pair's crossing costs its slower time.
- A and B cross in two. A brings the torch back in one. C and D cross together in ten. B, who was left on the far side, returns in two. A and B cross again in two. The sum is 2+1+10+2+2=17.
- For separate escorts let A cross with D in ten and return in one, cross with C in seven and return in one, then cross with B in two. This also leaves all four across and takes 10+1+7+1+2=21.
- The first plan spends three on the two returns and ten on one combined crossing for C and D. The second spends two on the returns and seventeen on their separate crossings. With the remaining crossings included, the first plan saves four among these two legal choices.
The two schedules take 17 and 21 time units. The combined slow crossing saves four in this comparison.
Identify a heavier coin among nine
Design two weighings to identify a single known-heavier coin among nine. State how to interpret left-heavy, right-heavy and balance in each branch.
- Divide the nine coins into groups A, B and C of three each. Compare A with B on the balance. If the left pan is heavier, the exceptional coin is in A. If the right pan is heavier, it is in B. A balance puts it in C.
- The remaining group contains the heavier coin and two equal ordinary coins. Set the group in any fixed order and compare its first coin with its second.
- If the left pan is heavier, select the first coin. If the right pan is heavier, select the second. If the pans balance, both weighed coins are ordinary and the unweighed third is exceptional.
- Every possible exceptional coin reaches a distinct pair of outcomes. One weighing yields at most three outcomes, so a single weighing cannot distinguish nine possibilities under the stated balance model.
Compare two groups of three, then two coins from the candidate group. The two outcomes identify the heavier one.
Find a zero-xor move in three heaps
For heaps 3,4,5 find the xor, give a legal move to zero xor and verify the resulting sizes.
- Write three as 011, four as 100 and five as 101 in binary. Columnwise addition modulo two gives 011⊕100⊕101=010, or two.
- The highest set bit of the sum is worth two. The heap of size three has that bit set, so replacing its size by 3⊕2 clears that leading changed bit and gives the smaller value one.
- Removing two tokens from that heap is a legal move. The new position is (1,4,5).
- Its xor is 001⊕100⊕101=000. Equivalently 4⊕5=1, which cancels the remaining one.
The xor is two. Reduce the heap of three to one and the new xor is zero.
Turn off three lights in a line
Each press toggles its light and any immediate neighbors. From (1,0,1), find all solutions modulo two and verify the presses directly.
- Let x₁,x₂,x₃ be the parities of the counts of the three switches. To cancel the initial vector (1,0,1), the needed toggle parities give x₁+x₂=1, x₁+x₂+x₃=0 and x₂+x₃=1 in arithmetic modulo two.
- Subtract the first equation from the second to obtain x₃=1. The third equation then gives x₂=0, and the first gives x₁=1.
- These substitutions determine every coordinate, so (1,0,1) is the unique parity solution. It says to press switches one and three an odd number of times and switch two an even number of times.
- Pressing switch one once turns (1,0,1) into (0,1,1). Pressing switch three once then produces (0,0,0), as required.
The unique parity solution is (1,0,1). Press switches one and three once each.
Verify a magic square and its center
For rows (8,1,6), (3,5,7), (4,9,2), check all entries and sums. Use the four lines through the center to explain five.
- The array uses each number one through nine once. The row sums are 8+1+6=15, 3+5+7=15 and 4+9+2=15. The column sums are 8+3+4=15, 1+5+9=15 and 6+7+2=15.
- The two diagonal sums are 8+5+2=15 and 6+5+4=15. The common line total must be fifteen whenever the three rows partition the numbers one through nine and have equal sums, since their total is forty-five.
- Consider the middle row, middle column and the two diagonals. Together they include every noncentral entry once and the center four times. If the center is c, the sum of their totals is therefore 45+3c.
- Those four totals are also 4·15=60, so 3c=15 and c=5. The argument explains the center in any such square with these nine entries.
Each row, column and diagonal sums to fifteen, and 45+3c=60 gives center five.
Update three-door odds after a door opens
Initially choose A under the stated uniform host rule. The host opens C. Find the probability of this observation and the posterior prize probabilities for A and B.
- The prize is initially equally likely at A, B and C. When the prize is at A, the host opens C with probability one half. When it is at B, the host has to open C. When it is at C, the host never opens it.
- The joint probabilities of those three prize placements with the observed opening are respectively (1/3)(1/2)=1/6, (1/3)·1=1/3 and (1/3)·0=0.
- Their sum is 1/2, the probability of observing C open. Within this set of outcomes the chance that the prize is at A is (1/6)/(1/2)=1/3.
- The chance that it is at B is (1/3)/(1/2)=2/3. After observing C, switching to B is exactly the decision associated with the latter probability under this host rule.
C opens with probability one half. Conditional prize probabilities at A and B are one third and two thirds.
Compare three nontransitive dice
Let A have faces (2,2,5), B (1,4,4), and C (3,3,3), each face equally likely. Verify the probabilities of A beating B, B beating C, and C beating A.
- For A against B the outcomes form nine equally probable ordered face pairs. Each of A's two faces labeled two beats B only on its face labeled one, contributing two wins. A's face labeled five beats all three faces of B, contributing three.
- That gives five wins in nine for A against B. B beats C precisely on its two faces labeled four because C always shows three. Thus B wins with probability two thirds.
- C beats A whenever A shows two, which occupies two faces. It loses when A shows five. Hence C beats A with probability two thirds.
- The comparisons are between independent face selections, with no ties in the listed pairs. Each probability exceeds one half, producing a cycle even though the individual numerical faces are ordered.
The three probabilities are 5/9, 2/3 and 2/3 in the specified cycle.
Count four-bead binary necklaces
Up to rotation only, count binary necklaces with four positions. Count colorings fixed by each rotation and give the orbit count.
- The identity rotation fixes all 2⁴=16 binary words. A rotation by one position cycles all four places. Its fixed words are the two constant words.
- A rotation by two positions exchanges positions one and three and also two and four. Each pair can choose its own common bit, giving 2²=4 fixed words. A rotation by three cycles all four places and fixes two.
- The orbit-counting average is (16+2+4+2)/4=6. This handles words with shorter periods through their additional fixed rotations.
- As a check, representatives may be taken as 0000, 0001, 0011, 0101, 0111 and 1111. The two representatives with two ones distinguish neighboring ones from alternating ones.
The four rotation fixed counts are 16, 2, 4 and 2. Their average is six.
Try it yourself
Remove cells (1,1) and (2,2) from a two-by-three grid. Count the remaining colors and decide whether two dominoes can cover them.
Show the answer and reasoning
One even-color and three odd-color squares remain. Two dominoes cannot cover them.
Before removing any squares, the two rows alternate colors and together contain three of each. Both removed positions have even sum, since 1+1=2 and 2+2=4. Their removal leaves one even-sum square and three odd-sum squares. This leaves four squares, so the required area is that of two dominoes. Every horizontal or vertical unit step changes coordinate-sum parity. Thus each of the two dominoes would have to cover one square of each color. The even-sum color has only one remaining square, so two dominoes cannot tile the board.
Start with 211. Reverse its digits, find the positive difference and reverse all three places of that difference. Explain the zero's role and give the total.
Show the answer and reasoning
The reversal is 112, the difference is 099 in three places, and 99+990=1089.
Reverse the three digits of 211 to obtain 112. Subtract the smaller number from the larger to obtain 211−112=99. Write that difference in three places as 099. Reversing the full three-place numeral gives 990. Dropping the leading zero before reversal would instead act only on the two visible nines. Add numerically to get 99+990=1089. The initial outer digits differ by one, and one times ninety-nine accounts for the difference. The leading zero remains a place in the representation during reversal. It moves to the units place of 990, so preserving it makes the stated three-place rule apply.
Count the two colors and explain why a closed tour visiting each square once cannot exist.
Show the answer and reasoning
There are eighteen even-color cells and seventeen odd-color cells. A closed tour is impossible.
Take the color of (1,1) to be even, using the parity of row plus column. The odd-numbered rows each contain four even and three odd cells, since they begin with even and span seven columns. The even-numbered rows each contain three even and four odd cells. Across three odd-numbered and two even-numbered rows, the totals are 3·4+2·3=18 even and 3·3+2·4=17 odd. A knight changes its row and column by amounts of magnitudes one and two, so the sum changes by an odd number. Each move interchanges the two colors. A closed knight tour alternates colors and has equally many vertices of each color, counting its start only once around the cycle. The unequal counts here exclude a closed tour.
Count how many other entries a tile passes in the nonblank list during a vertical move. Apply the parity condition to swapping only labels one and two in the solved configuration.
Show the answer and reasoning
A vertical move crosses two listed tiles and preserves parity. The swap of tiles one and two is unreachable.
In a vertical move on a width-three board, the moved tile shifts by three positions in row-major order to the former blank. Exactly two other cells lie strictly between its old and new positions. After the blank is omitted from the list, the tile trades its relative order with those two other tiles. Each crossing changes the inversion count by one in parity, so the net parity remains even. A horizontal move crosses no listed tile. The solved list has zero inversions. Exchanging only labels one and two contributes a single inversion. Comparisons with labels three through eight are unaffected because both exchanged labels remain smaller. Thus the exchanged list has odd inversion parity and the solved list even. Legal moves preserve that parity on width three, so the exchange cannot be obtained.
Remove (1,1) from a four-by-four grid with rows down and columns right. Identify the central piece and explain the four remaining two-by-two tilings and the total piece count.
Show the answer and reasoning
The central tromino covers (2,3),(3,2),(3,3). One piece per quadrant makes five pieces in all.
Separate the four-by-four board into four two-by-two quadrants. The removed cell (1,1) belongs to the northwest quadrant. At the central corner of each of the other three quadrants mark cells (2,3), (3,2) and (3,3). Those three marked cells are the central two-by-two square without (2,2), so they form one L tromino. Place it there. This gives the northeast, southwest and southeast quadrants one occupied cell each. In the northwest quadrant the original missing cell plays the role of the one unavailable cell. Each quadrant now has exactly three available cells. Any three cells of a two-by-two block form an L, so each quadrant can be covered by one piece. There is one central piece and one piece in each quadrant, totaling five. Their coverage is disjoint and includes all 4·4−1=15 required cells.
Explain why a five-unit quantity is impossible under the stated rules. Construct a legal sequence measuring eight in the ten-unit jug.
Show the answer and reasoning
Amounts stay even. Five is impossible, and the given sequence ends at (0,8).
Amounts initially equal zero and both capacities are even. Filling or emptying gives an even amount, and a pour transfers the smaller of an even source amount and an even remaining capacity. Both components therefore stay even after every move. Write (a,b) for the amount in the six- and ten-unit jugs. From (0,0), fill and pour to get (6,0) then (0,6). A second fill gives (6,6) and a pour filling the large jug leaves (2,10). Empty the large jug to get (2,0) and pour the remainder into it to get (0,2). Fill the small jug to reach (6,2). It can empty entirely into the large jug because eight units of space remain. The result is (0,8), completing the construction. The five-unit target is impossible in either jug by the evenness invariant, which persists even on paths that fill the larger jug along the way.
Use the recurrence for the even and odd cases to find the surviving label for n=13. Check the power-of-two formula.
Show the answer and reasoning
The survivor is label eleven by either calculation.
With J(n) the one-based surviving label, the deletion rules yield J(2m)=2J(m)−1 and J(2m+1)=2J(m)+1 for m≥1, with J(1)=1. The odd case starts the smaller game at original label three after deleting label one. The recurrence gives J(3)=2J(1)+1=3. It then gives J(6)=2J(3)−1=5. For thirteen, the odd rule gives J(13)=2J(6)+1=11. This calculation reaches the starting case through the sizes thirteen, six, three and one. The largest power of two not exceeding thirteen is eight. Writing thirteen as eight plus five gives the formula J(13)=2·5+1=11, agreeing with the recurrence.
Find the largest unattainable amount, show directly that it is unattainable, and represent the next four consecutive amounts to justify all larger ones.
Show the answer and reasoning
The largest missing total is seventeen. The next four totals generate the entire tail by adding fours.
If 17=4a+7b for nonnegative integers a,b, reduction modulo four gives 3b≡1. Since the inverse of three modulo four is three, it forces b≡3 modulo four. The smallest nonnegative such b is three, which makes 7b≥21 and gives no representation of seventeen. Now 18=7+7+4 and 19=7+4+4+4. The next two totals are 20=5·4 and 21=3·7. These four consecutive totals cover every residue modulo four, with one representative in the range eighteen through twenty-one. Every larger total is the appropriate representative plus a nonnegative multiple of four. Thus all amounts above seventeen are attainable, and seventeen is the greatest missing value.
In the subtraction game allowing removal of one through four, give a winning first move and the response to each subsequent opposing removal.
Show the answer and reasoning
Remove two tokens to leave fifteen, then answer any opposing k with 5−k.
Remove two of the seventeen tokens to leave fifteen. This passes a multiple of five to the other player. If the other player takes k with 1≤k≤4, take 5−k. This amount is also between one and four. On any positive multiple of five, the opposing removal leaves at least 5−k, so the reply is legal. The two moves reduce the prior multiple of five by five. Starting from fifteen, the positive counts the opponent receives are fifteen, ten and five. The reply to a move from five removes the last tokens. The opponent then has no legal move, so the first player wins under last-move-wins normal play.
In a heap a move removes one or three tokens if available. Compute the values for heaps zero through eight. Determine whether the first player wins in the disjunctive position (7,8,3).
Show the answer and reasoning
The nine values alternate zero and one from zero. Position (7,8,3) has zero xor and is losing.
Let g(n) be the least nonnegative integer absent from the values of legal followers of a single heap of size n. With no legal move g(0)=0. A heap of size one can reach zero, so g(1)=1. A heap of size two can reach only size one, so g(2)=0. For n≥3 the allowable subtractions one and three give followers of parity opposite to n. If the earlier values are zero on even sizes and one on odd sizes, both followers have the same value. Their least excluded value is one for odd n and zero for even n. Induction gives the list 0,1,0,1,0,1,0,1,0 from size zero through eight. In particular g(7)=1, g(8)=0 and g(3)=1. The disjunctive game's value is 1⊕0⊕1=0. Every move changes one heap's value to the other bit, making the total xor one. The zero value is losing for the first player under optimal normal play.
Find the minimum moves, show the largest-disc lower bound and describe the matching recursive construction.
Show the answer and reasoning
A minimum of fifteen moves is attained as 7+1+7.
To move the largest of four discs to the destination, all three smaller discs must first be arranged together on the remaining peg. At least 2³−1=7 moves of those discs precede its direct move when it moves just once. After that move the upper stack must be transferred onto it from the remaining peg. That needs at least seven further moves. If the largest moves more than once, the bounds from the stack before its first move and the stack after its last move still give seven each, with at least two intervening largest-disc moves. To attain the lower bound, move the upper three to the spare peg in seven, move the largest directly to the goal in one, then move the upper three onto it in seven. The largest underneath a smaller stack does not prevent any of its transfers. The minimum is therefore 7+1+7=15. The transfer of three used in this construction is the same smaller instance of the recurrence for legal ordered transfers.
Use a four-cycle on vertices 1,2,3,4 with edge 1–3 added. Give the degrees, choose endpoints and write a trail using each edge once.
Show the answer and reasoning
The endpoints are one and three. A trail is 1–2–3–4–1–3.
The square contributes degree two at every vertex. Its added edge 1–3 raises the degrees at one and three to three. The degree list in order is thus (3,2,3,2). In an undirected trail using all edges, every intermediate visit pairs a used arrival with a different departure. A closed such trail would require all degrees even. With two odd vertices, the endpoints must be one and three. Take the vertex sequence 1,2,3,4,1,3. Its first four traversals are the four distinct square edges, and its final step uses the diagonal. This trail covers each of the five edges once. It begins at one and ends at three, as required by the parity argument.
Solve i+j=3 and i+2j=1 modulo five for the unique position. Check both labels.
Show the answer and reasoning
The unique position is row zero, column three modulo five.
Subtract i+j=3 from i+2j=1, both modulo five. This isolates j=1−3=−2≡3 modulo five. Substitute j=3 into the first equation. It gives i≡3−3=0. These eliminations specify a unique residue class for each coordinate. In row zero and column three, the first label is 0+3=3. The second is 0+2·3=6≡1 modulo five. The two checked labels match the specified overlay. The way the equation isolates j with coefficient one is what makes the inverse unique for this pair.
Complete the pair (0,1,2),(1,1,0) under the all-equal-or-all-distinct rule. Count all unordered matching triples in the full three-feature deck.
Show the answer and reasoning
The completing card is (2,1,1). The full deck has 117 matching triples.
Use arithmetic modulo three for each of the features. A valid triple has sum zero in each coordinate. The value completing each coordinate is therefore the negative of the corresponding sum of the first two cards. The coordinate sums for (0,1,2) and (1,1,0) are (1,2,2) modulo three. Their negatives give the completing card (2,1,1). The first and third coordinates then have three distinct values and the middle has three equal values. There are 27 cards in the three-feature deck, one for every triple of feature values. Each pair of distinct cards has exactly one completing card, distinct from both since the original cards differ in at least one feature. There are binomial(27,2)=351 unordered pairs. Each matching triple is counted through its three distinct pairs. Thus the number of unordered matching triples is 351/3=117.
For the four numbers 1,2,3,5, use counting to prove two different subsets have equal sums. Exhibit two disjoint nonempty solutions.
Show the answer and reasoning
The subsets {2,3} and {5} are disjoint and each sums to five.
The four distinct numbers have 2⁴=16 subsets, including the empty set. Any subset sum is an integer between zero and their total 1+2+3+5=11. There are twelve possible sums in that inclusive interval. By the pigeonhole principle, two distinct subsets have the same sum. Removing their common elements from both preserves equality and leaves disjoint selections. The disjoint selections cannot have one empty and the other nonempty, since all numbers are positive. If both were empty, the original subsets would have been identical. Here the subsets {2,3} and {5} give an explicit disjoint example. Each has sum five, so one can exhibit a collision without enumerating all sixteen subsets.
For three independent uniform choices among ten labels, find the exact probability of a match and compare it with the pair-union bound.
Show the answer and reasoning
The exact match probability is 7/25, below the union bound 3/10.
For three ordered draws from ten labels, the number of possible lists is 10³=1000. The lists with no repeat have ten choices for the first label, nine for the second and eight for the third. There are therefore 10·9·8=720 lists without a match. Their complement has probability (1000−720)/1000=0.28=7/25. There are binomial(3,2)=3 pairs. Each pair agrees with probability one tenth, so the union bound gives at most three tenths. The upper bound is 0.30 and the exact value is 0.28. Pair-agreement events can coincide, for example when all three labels are equal, so the sum of their probabilities can exceed the probability of their union.
For independent tosses with head probability one third, find the expected number of tosses to two consecutive heads from an empty start. Use two states and justify finite expectation.
Show the answer and reasoning
The expected wait is twelve tosses.
Write p=1/3 for the head probability. In disjoint pairs of tosses the event HH has probability p²=1/9. Independent blocks therefore bound the waiting tail by a geometric tail, making the expectations finite. Let E₀ be the mean additional wait with no current head and E_H the mean with a final head. From the empty state, E₀=1+(1−p)E₀+pE_H, which rearranges to E₀=1/p+E_H. From the final-head state, a head completes the pattern and a tail restarts from the empty state. Thus E_H=1+(1−p)E₀. Substitution into the first equation gives pE₀=1/p+1. It follows that E₀=(1+p)/p². At p=1/3 the expected wait is (4/3)/(1/9)=12 tosses. The expectation of twelve describes a long-run mean under the stated toss rule.
On a four-by-three grid from (0,0) to (4,3) with east and north steps, count all paths and those passing through (2,1). Find the number avoiding it.
Show the answer and reasoning
Of 35 routes, 18 pass through the point and 17 avoid it.
Each route from (0,0) to (4,3) contains four east steps and three north steps. Choosing the three north slots among seven gives binomial(7,3)=35 routes. A route through (2,1) begins with two east steps and one north step in any order. There are binomial(3,1)=3 choices. The remaining route uses two east steps and two north steps, giving binomial(4,2)=6 choices. Pairing each prefix with each suffix gives 3·6=18 routes through the designated point. The count avoiding it is 35−18=17. Each route through the point was counted once by its unique splitting into prefix and suffix.
What to carry forward
- A move invariant converts a search problem into a necessary-condition test.
- A proof of reachability supplies legal transitions from the stated start.
- Unit-length layers minimize moves. A positive edge cost allows a separate minimum-time calculation.
- A decision tree counts the answers a procedure can distinguish within its allowed depth.
- A proof by induction can work by making the smaller problem flexible enough to reuse.
- Conditioning depends on the observation mechanism, and stopping can depend on overlap between patterns.
- Orbits count arrangements up to a declared symmetry, and exact endpoint conditions determine when a bound is attained.
- A repeatable strategy can generate a new puzzle family after each legal response is justified.
References
Sources for the concepts and teaching approaches in this article.
- Mathematics for Computer Science, §5.4.3, §5.4.3, Definition 5.4.5 and the Invariant Principle, online lines 4133–4153.Eric Lehman, F. Thomson Leighton and Albert R. MeyerPrimary · PDFReachability and preserved predicatesStrengthen the induction hypothesis to move the holeFill, empty and pour as exact transitionsConstruct and bound an ordered disk transferSubset-sum collisions by pigeonholeCounting fixed numbers of positionsThe empty product acts as the multiplicative identity
- Decimal places and expanded formOpenStaxPrimary
- Legal moves and parity in the sliding puzzleAaron F. ArcherPrimary · PDF
- Relabeling a circular elimination recurrenceRonald L. Graham, Donald E. Knuth and Oren PatashnikPrimary · PDF
- Crossing times and legal torch schedulesGünter RotePrimary · PDF
Massachusetts Institute of Technology4 sources
- Outcome trees count distinguishable answersMIT 6.006 course staffPrimary · PDF
- Shortest paths by breadth-first layersMIT 6.006 course staffPrimary · PDF
- A forced monochromatic triangleMIT 18.204 Ramsey numbers course manuscriptPrimary · PDF
- Count collision probabilities by counting the complementMIT 6.042 course notesPrimary · PDF
- Normal play and least-missing game valuesThomas S. FergusonPrimary · PDF
- Winning and losing Nim positionsCharles L. BoutonPrimary · PDF
- Light switches as linear combinations modulo twoMarlow Anderson and Todd FeilPrimary · PDF
- The degree obstruction in a bridge walkLeonhard EulerPrimary
- The center of a three-by-three magic squareKent State University mathematics teaching notesPrimary · PDF
- Orthogonal residue-square constructionsNeil StricklandPrimary
- Feature triples and points over the field of three elementsBenjamin Lent Davis and Diane MaclaganPrimary · PDF
- Switching under specified host behaviorRichard D. GillPrimary · PDF
- Pattern waiting times by first-step recurrencesUC Berkeley Data 140 course textPrimary
- Absorbing endpoint odds by a difference equationYen-Chi ChenPrimary
- Complete a two-player interrupted game to a fixed horizonBlaise Pascal and Pierre de FermatPrimary · PDF
- Pairwise dice comparisons and cyclesAshwin Sah and Mehtaab SawhneyPrimary · PDF
- Fixed objects and orbit countsBruce E. SaganPrimary · PDF
- Binary windows from complete directed walksNicolaas G. de BruijnPrimary · PDF
- Two complementary irrational floor sequencesEzra BrownPrimary · PDF
- Length comparison in a triangleEuclid, translated by David E. JoycePrimary
- Find the greatest common measureEuclid, English presentation by David E. JoycePrimary