Adding Two
The number \(4\) is written on a board. In one move, one may add \(2\). Can \(99\) be obtained?
Parity does not change.
The initial number is even, and adding \(2\) preserves parity. The number \(99\) is odd, so it cannot be obtained.
Chapter
Theory
An invariant is a quantity or property that does not change under the allowed operations. If the initial and final states have different invariant values, then the transition is impossible.
In olympiad problems, the invariant is often hidden. Look among parity, sum, residue modulo a number, coloring, product of signs, number of objects of a certain color, or permutation parity.
Ask: what does the operation definitely not change? If a number of objects changes, check parity. If objects are moved, check the sum. If the operation is local on a board, color the board. If signs change, check the product or number of minus signs.
Sometimes the invariant is not the quantity itself, but its residue. For example, a sum may change, but always by a multiple of \(3\), so the sum modulo \(3\) is preserved.
Examples
The most common invariant is parity.
Problem. The number \(0\) is written on a board. In one move, one may add \(2\) or subtract \(2\). Can \(101\) be obtained?
The parity of the number does not change: an even number is added or subtracted. Initially \(0\) is even, while \(101\) is odd. Therefore \(101\) cannot be obtained.
Comment. Invariant: residue modulo \(2\).
The number of heads changes by an even number.
Problem. There are \(15\) coins heads up. In one move, exactly two coins are flipped. Can all coins become tails up?
The number of heads changes by \(-2\), \(0\), or \(2\). Therefore its parity is preserved. Initially there are \(15\) heads, odd; in the final state there would be \(0\), even. Impossible.
Comment. It does not matter which coins are flipped.
The operation moves one unit from one place to another.
Problem. There are two piles with \(7\) and \(11\) stones. In one move, one stone may be moved from one pile to the other. Can the piles become \(5\) and \(20\)?
The total number of stones is preserved. Initially it is \(18\), while \(5\) and \(20\) total \(25\). Therefore it is impossible.
Comment. An invariant may be very simple.
The sum may change, but the residue is preserved.
Problem. A sum is written on the board. In one move, one may add \(6\) or subtract \(9\). If the initial sum is \(2\), can \(100\) be obtained?
Both changes are divisible by \(3\), so the sum modulo \(3\) is preserved. Initially it is \(2\pmod3\), while \(100\equiv1\pmod3\). Therefore \(100\) cannot be obtained.
Comment. Invariant: sum modulo \(3\).
A domino covers one black and one white cell.
Problem. Can an \(8\) by \(8\) board be tiled by dominoes if two opposite corner cells are removed?
In chessboard coloring, opposite corners have the same color. Removing them leaves two fewer cells of one color than the other. Each domino covers one black and one white cell, so tiling is impossible.
Comment. This is the main coloring-invariant example.
Changing two signs preserves the product.
Problem. There are \(9\) plus signs on the board. In one move, exactly two signs may be changed. Can we obtain exactly one minus sign?
The product of all signs does not change when two signs are changed: it is multiplied by \((-1)^2=1\). Initially the product is \(+1\), while with one minus it is \(-1\). Impossible.
Comment. One may also track the parity of the number of minus signs.
Some moves necessarily change color.
Problem. A knight stands on a black square of a chessboard. Can it be on a black square after \(7\) moves?
A knight move always changes the color of the square. After an odd number of moves, the color is opposite to the initial one. After \(7\) moves, the knight is on a white square, so it cannot be on black.
Comment. Invariant: color plus parity of the number of moves.
Sometimes the preserved quantity is the sum of two parities.
Problem. Starting from \(12345678\), we want to obtain \(87654321\) by adjacent swaps in exactly \(27\) moves. Is it possible?
One adjacent swap changes the parity of the number of inversions. Initially there are \(0\) inversions. The reversed string has \(C(8,2)=28\) inversions, again even. After \(27\) swaps, inversion parity would be odd, contradiction. Impossible.
Comment. Invariant: inversion parity matches the parity of the number of adjacent swaps made.
Problems
The number \(4\) is written on a board. In one move, one may add \(2\). Can \(99\) be obtained?
Parity does not change.
The initial number is even, and adding \(2\) preserves parity. The number \(99\) is odd, so it cannot be obtained.
There are \(9\) coins heads up. In one move, exactly two coins are flipped. Can all coins become tails up?
The parity of the number of heads is preserved.
The number of heads changes by \(-2\), \(0\), or \(2\), so its parity is preserved. It starts at \(9\) and would need to become \(0\). Odd cannot become even.
There are piles of \(3\), \(5\), and \(7\) stones. In one move, one stone may be moved from one pile to another. Can the piles become \(4\), \(6\), and \(10\)?
The total number of stones is preserved.
Initially there are \(15\) stones, while the target has \(20\). Since moving a stone does not change the total, the target is impossible.
A number on the board may be changed by adding \(6\) or subtracting \(9\). Starting from \(5\), can one obtain \(100\)?
The changes are multiples of \(3\).
The residue modulo \(3\) is preserved. \(5\equiv2\pmod3\), while \(100\equiv1\pmod3\). Therefore \(100\) cannot be obtained.
There are \(8\) plus signs on the board. In one move, two signs may be changed to the opposite signs. Can exactly \(3\) minuses be obtained?
The parity of the number of minuses is preserved.
Changing two signs changes the number of minuses by \(-2\), \(0\), or \(2\). Its parity is preserved. Initially it is \(0\), but the target is \(3\), impossible.
There are \(7\) plus signs on the board. In one move, exactly two signs are changed. Can all signs become minus?
The product of all signs is preserved.
Changing two signs multiplies the product by \((-1)^2=1\). Initially the product is \(+1\). With \(7\) minuses, the product is \(-1\). Impossible.
Three boxes contain \(1\), \(4\), and \(9\) tokens. In one move, one token may be moved from one box to another. Can we obtain \(2\), \(6\), and \(7\)?
Check the total.
Initially there are \(14\) tokens, while the target has \(15\). Moving a token preserves the total, so the target is impossible.
There are \(15\) coins heads up. In one move, any \(4\) coins are flipped. Can exactly \(2\) heads be obtained?
The parity of heads is preserved because an even number of coins is flipped.
If \(h\) heads are among the flipped coins, the number of heads changes by \(4-2h\), an even number. Parity is preserved. Initially \(15\) is odd; \(2\) is even. Impossible.
For a pair \((a,b)\), the move \((a,b) o(a+1,b-1)\) is allowed. Can \((10,5)\) be obtained from \((3,8)\)?
The sum \(a+b\) is preserved.
The initial sum is \(11\), the target sum is \(15\). The operation preserves the sum, so it is impossible.
On a chessboard, a token starts on a black square. In one move it moves to a diagonally adjacent square. Can it reach a white square?
A diagonal move preserves the square color.
In chessboard coloring, diagonally adjacent squares have the same color. Thus the token's color is preserved. It cannot move from black to white.
There are \(6\) plus signs on the board. In one move, exactly \(4\) signs may be changed. Can exactly one minus be obtained?
The product of signs is preserved.
Changing \(4\) signs multiplies the product by \((-1)^4=1\). Initially the product is \(+1\), while with one minus it is \(-1\). Impossible.
Numbers are written on a board. In one move, two numbers may be increased by \(1\) and one number decreased by \(2\). Prove that the sum modulo \(3\) does not change.
Compute the change in the sum.
In one move, the sum changes by \(1+1-2=0\). Thus the sum itself is preserved, and therefore its residue modulo \(3\) is preserved.
There are \(2025\) lamps switched off. In one move, exactly \(100\) lamps may be toggled. Can all lamps be switched on?
The parity of the number of switched-on lamps is preserved.
If \(h\) of the chosen lamps are on, the number of on lamps changes by \(100-2h\), an even number. Initially \(0\) lamps are on, even; finally \(2025\) would be on, odd. Impossible.
There are tokens in boxes. In one move, one may add \(4\) tokens to one box and remove \(1\) token from another. Prove that the total number of tokens modulo \(3\) is preserved.
The total changes by \(3\).
In one move, the total number of tokens changes by \(4-1=3\), so its residue modulo \(3\) does not change.
Can an \(8\) by \(8\) board be tiled with dominoes if two opposite corner cells are removed?
In chessboard coloring, opposite corners have the same color.
The original board has \(32\) black and \(32\) white cells. Opposite corners have the same color, so after removal there are \(30\) cells of one color and \(32\) of the other. Each domino covers one black and one white cell, so tiling is impossible.
In a \(4\) by \(4\) table, all signs are \(+\). In one move, one may change all signs in a row or a column. Can a table with exactly one minus be obtained?
Four signs change, so the product of all signs is preserved.
Each move changes \(4\) signs, so the product of all \(16\) signs is multiplied by \((-1)^4=1\). Initially the product is \(+1\). With exactly one minus, it is \(-1\). Impossible.
Can signs \(+\) and \(-\) be placed before \(1,2,\ldots,10\) so that the sum becomes \(0\)?
Look at the parity of the sum.
The sum \(1+2+\cdots+10=55\) is odd. Changing the sign of \(a\) changes the sum by \(-2a\), an even number. Thus the parity of the sum remains odd. Zero is even, so it is impossible.
A knight stands on a white square of a chessboard. Can it be on a white square after \(2025\) moves?
Every knight move changes the square color.
A knight move changes the square color. After an odd number of moves, the color is opposite to the initial one. Since \(2025\) is odd, the knight is on a black square, not white.
The number \(1\) is written on a board. In one move, \(x\) may be replaced by \(x+6\) or \(x+10\). Can \(100\) be obtained?
Both increments are even.
Parity is preserved because even numbers are added. The initial number \(1\) is odd, while \(100\) is even. Impossible.
A token starts at cell \((0,0)\). In one move it may go to \((x+2,y+1)\) or \((x+1,y+2)\). Can it reach \((10,10)\)?
Look at the sum of coordinates modulo \(3\).
Each move increases \(x+y\) by \(3\). Thus \(x+y\) modulo \(3\) is preserved and equals \(0\). At \((10,10)\), the coordinate sum is \(20\equiv2\pmod3\). It cannot be reached.
In a \(6\) by \(6\) table, all entries are \(1\). In one move, one may change signs of all entries in one chosen row or column. Can one obtain a table with exactly one entry \(-1\) and all others \(1\)?
Each move changes \(6\) signs.
The product of all \(36\) entries is preserved: one move multiplies it by \((-1)^6=1\). Initially the product is \(1\). A table with one \(-1\) has product \(-1\). Thus it is unreachable.
A knight stands on a black square. Prove that it cannot return to the same square in exactly \(15\) moves.
The color changes after each move.
Every knight move changes the square color. After \(15\) moves, since \(15\) is odd, the knight is on the opposite color. The starting square is black, so it cannot return to it.
Given the triple \((1,1,1)\). In one move, one may add \(2\) to two numbers and subtract \(1\) from the third. Can \((10,10,10)\) be obtained?
Look at the sum modulo \(3\).
One move changes the sum by \(2+2-1=3\), so the sum modulo \(3\) is preserved. Initially the sum is \(3\equiv0\pmod3\), finally \(30\equiv0\pmod3\), so this invariant does not forbid it. In fact the state is reachable: apply three moves, subtracting from a different coordinate each time; all coordinates increase by \(3\). Repeating this three-move cycle three times gives \((10,10,10)\).
Starting from \(12345678\), one move swaps two adjacent symbols. Can \(87654321\) be obtained in exactly \(27\) moves?
An adjacent swap changes inversion parity.
The initial number of inversions is \(0\). Each adjacent swap changes inversion parity. After \(27\) moves, inversion parity would be odd. But in \(87654321\), the number of inversions is \(C(8,2)=28\), which is even. Contradiction; exactly \(27\) moves are impossible.
Ladders