Problem 6.1. Masha placed the numbers from 1 to 16 in the cells of a $4 \times 4$ table so that any two numbers differing by one were in adjacent cells.

And Sasha erased all the numbers except for 1, 4, 9, and 16. What number was in the cell with the question mark?

|  | 1 |  | $?$ |
| :---: | :---: | :---: | :---: |
|  | 4 |  |  |
|  |  | 16 |  |
|  |  | 9 |  |
Answer: 13.

Solution. Since any two numbers that differ by one are in adjacent cells, the number in the upper left corner must be either 2 (neighbor of 1) or a number that has only one neighbor - 1 or 16. The second option does not work for us, so we can write the numbers 2 and 3 in the table.

| 2 | 1 |  | $?$ |
| :---: | :---: | :---: | :---: |
| 3 | 4 |  |  |
|  |  | 16 |  |
|  |  | 9 |  |

If the number 8 is to the right of the number 9, then the placement of the numbers $7,6,5$ is uniquely determined.

| 2 | 1 |  | $?$ |
| :---: | :---: | :---: | :---: |
| 3 | 4 | 5 | 6 |
|  |  | 16 | 7 |
|  |  | 9 | 8 |

But then we cannot place any number in the upper right corner, so this option does not work. It turns out that to the left of the number 9 is the number 8, and to the right is 10.

| 2 | 1 |  | $?$ |
| :---: | :---: | :---: | :---: |
| 3 | 4 |  |  |
|  |  | 16 |  |
|  | 8 | 9 | 10 |

In the left part of the table, the placement of the numbers $7,6,5$ is uniquely determined, and in the right part - 11 and 12.

| 2 | 1 |  | $?$ |
| :---: | :---: | :---: | :---: |
| 3 | 4 |  | 12 |
| 6 | 5 | 16 | 11 |
| 7 | 8 | 9 | 10 |

Next to the number 16, only the number 15 can stand. Now it only remains to write the numbers 13 and 14 into the table.

| 2 | 1 | 14 | 13 |
| :---: | :---: | :---: | :---: |
| 3 | 4 | 15 | 12 |
| 6 | 5 | 16 | 11 |
| 7 | 8 | 9 | 10 |