Subfield: Combinatorics


Question: The numbers $1,2, \ldots, 8$ are placed in the $3 \times 3$ grid below, leaving exactly one blank square. Such a placement is called okay if in every pair of adjacent squares, either one square is blank or the difference between the two numbers is at most 2 (two squares are considered adjacent if they share a common side). If reflections, rotations, etc. of placements are considered distinct, compute the number of distinct okay placements.

<img_3937>

Solution:
We say that two numbers are neighbors if they occupy adjacent squares, and that $a$ is a friend of $b$ if $0<|a-b| \leq 2$. Using this vocabulary, the problem's condition is that every pair of neighbors must be friends of each other. Each of the numbers 1 and 8 has two friends, and each number has at most four friends.

If there is no number written in the center square, then we must have one of the cycles in the figures below. For each cycle, there are 8 rotations. Thus there are 16 possible configurations with no number written in the center square.

| 2 | 1 | 3 |
| :--- | :--- | :--- |
| 4 | - | 5 |
| 6 | 8 | 7 |


| 3 | 1 | 2 |
| :--- | :--- | :--- |
| 5 | - | 4 |
| 7 | 8 | 6 |

Now assume that the center square contains the number $n$. Because $n$ has at least three neighbors, $n \neq 1$ and $n \neq 8$. First we show that 1 must be in a corner. If 1 is a neighbor of $n$, then one of the corners neighboring 1 must be empty, because 1 has only two friends ( 2 and $3)$. If $c$ is in the other corner neighboring 1 , then $\{n, c\}=\{2,3\}$. But then $n$ must have three



more friends $\left(n_{1}, n_{2}, n_{3}\right)$ other than 1 and $c$, for a total of five friends, which is impossible, as illustrated below. Therefore 1 must be in a corner.

| - | 1 | $c$ |
| :--- | :--- | :--- |
| $n_{1}$ | $n$ | $n_{2}$ |
|  | $n_{3}$ |  |

Now we show that 1 can only have one neighbor, i.e., one of the squares adjacent to 1 is empty. If 1 has two neighbors, then we have, up to a reflection and a rotation, the configuration shown below. Because 2 has only one more friend, the corner next to 2 is empty and $n=4$. Consequently, $m_{1}=5$ (refer to the figure below). Then 4 has one friend (namely 6) left with two neighbors $m_{2}$ and $m_{3}$, which is impossible. Thus 1 must have exactly one neighbor. An analogous argument shows that 8 must also be at a corner with exactly one neighbor.

| 1 | 2 | - |
| :--- | :--- | :--- |
| 3 | $n$ | $m_{3}$ |
| $m_{1}$ | $m_{2}$ |  |

Therefore, 8 and 1 must be in non-opposite corners, with the blank square between them. Thus, up to reflections and rotations, the only possible configuration is the one shown at left below.

| 1 | - | 8 |
| :--- | :--- | :--- |
| $m$ |  |  |
|  |  |  |


| 1 | - | 8 |
| :---: | :---: | :---: |
| $2 / 3$ | $4 / 5$ | $6 / 7$ |
| $3 / 2$ | $5 / 4$ | $7 / 6$ |

There are two possible values for $m$, namely 2 and 3 . For each of the cases $m=2$ and $m=3$, the rest of the configuration is uniquely determined, as illustrated in the figure above right. We summarize our process: there are four corner positions for 1; two (non-opposite) corner positions for 8 (after 1 is placed); and two choices for the number in the square neighboring 1 but not neighboring 8 . This leads to $4 \cdot 2 \cdot 2=16$ distinct configurations with a number written in the center square.

Therefore, there are 16 configurations in which the center square is blank and 16 configurations with a number in the center square, for a total of $\mathbf{3 2}$ distinct configurations.

Final answer: 32