Gabriel draws squares divided into nine cells and writes the natural numbers from 1 to 9, one in each cell. He then calculates the sum of the numbers in each row and each column. The figure shows one of Gabriel's squares; note that the sum of the numbers in the third row is $5+8+2=15$ and the sum of the numbers in the second column is $9+7+8=24$. In this example, the six sums are $6, 12, 15, 15, 18$, and 24.

| $\mathbf{6}$ | $\mathbf{9}$ | $\mathbf{3}$ | 18 |
| :--- | :--- | :--- | :--- |
| $\mathbf{4}$ | $\mathbf{7}$ | $\mathbf{1}$ | 12 |
| $\mathbf{5}$ | $\mathbf{8}$ | $\mathbf{2}$ | 15 |
| 15 | 24 | 6 |  |
|  |  |  |  |

a) Gabriel filled in a square and made only five sums: 9, 13, 14, 17, and 18. What is the missing sum?

b) Explain why it is not possible for all the sums in one of Gabriel's squares to be even numbers.

c) Fill in the square so that the sums are 7, 13, 14, 16, 18, and 22.

![](https://cdn.mathpix.com/cropped/2024_05_01_984603b876c0bc28095bg-04.jpg?height=237&width=237&top_left_y=1092&top_left_x=818)

## Combinatorics

#
Solution

a) Adding the sums of the rows is the same as adding all the numbers in the square; thus, the sum of the sums of the rows is $1+2+3+4+5+6+7+8+9=45$. The same can be said about the sum of the sums of the columns, and we conclude that the sum of all the sums is $2 \times 45=90$. Therefore, the missing sum is $90-(9+13+14+17+18)=90-71=19$.

b) $1^{\text {st }}$ solution: If all the sums were even, the sums of the three rows would be even and their sum would be even. But this is impossible because, as we saw above, the sum of the sums of the three rows is 45, which is an odd number.

$2^{\text{nd}}$ solution: When distributing the numbers in the square, a row can have at most three odd numbers. On the other hand, there are five odd numbers from 1 to 9, namely, 1, 3, 5, 7, and 9. The ways to write 5 as a sum of integers less than or equal to 3 are $5=2+3=1+1+3=1+2+2$. Since in any of these sums the terms 1 or 3 appear, we conclude that at least one row of a filled square will contain one or three odd numbers, with the rest being even. In any case, we obtain a row whose sum is odd.

c) Let's extend this solution a bit to determine not just one, but all the squares that have the given sums. Before starting, we note that swapping the order of two rows (or two columns) does not change the sums of a square. The six numbers in the final result must be divided into two groups of three numbers each, whose sums are equal to 45. In the first group, each number is the sum of a row, and in the other, the sum of each column. According to the previous item, each group must contain an odd number; thus, 7 and 13 must be in different sets. It immediately follows that the only possibility is to separate the sums into the groups 7, 16, 22 and 13, 14, 18; we can then assume that the sums of the rows are 7, 16, 22 and the sums of the columns are 13, 14, 18.

Since the only way to get the sum 7 is $1+2+4=7$, we can start filling in the square as follows:

![](https://cdn.mathpix.com/cropped/2024_05_01_984603b876c0bc28095bg-22.jpg?height=134&width=214&top_left_y=1686&top_left_x=824)

Suppose the sum of the second row is 22; the only possibilities for the sum 22 are $5+8+9=22$ and $6+7+9=22$, which we will consider separately.

Suppose first that the numbers 5, 8, and 9 appear in the second row. Here the 5 cannot appear in the column of the 4, because $4+5=9$ and to obtain one of the sums 13, 14, or 18 in that column, the third number would have to be 4, 5, or 9, respectively, which cannot happen since the 4 has already been used while 5 and 9 appear in the second row; a similar argument shows that the 9 also cannot appear in the column of the 4, i.e., the 8 appears below the 4. Since $4+8=12$ and both 1 and 2 have already been used, the sum of this column cannot be 13 or 14; thus, the sum is 18.

![](https://cdn.mathpix.com/cropped/2024_05_01_984603b876c0bc28095bg-22.jpg?height=157&width=240&top_left_y=2234&top_left_x=814)

We can now complete the square in the following ways:

| 1 | 2 | 4 |
| :---: | :---: | :---: |
| 5 | 9 | 8 |
| 2 | 22 |  |
| 7 | 3 | 6 |
| 13 | 14 | 18 |


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

We leave it to the reader to show that when the numbers 6, 7, and 9 appear in the second row, the possibilities are:

![](https://cdn.mathpix.com/cropped/2024_05_01_984603b876c0bc28095bg-23.jpg?height=180&width=1336&top_left_y=407&top_left_x=474)

Thus, there are only six squares with the sums given in the problem, up to the swapping of rows, swapping of columns, and swapping of rows with columns.

## Combinatorics

#