In how many ways can we place 8 digits equal to 1 and 8 digits equal to $0$ on a $4 \times 4$ board so that the sums of the numbers written in each row and column are the same?

| 1 | 0 | 1 | 0 |
| :--- | :--- | :--- | :--- |
| 0 | 1 | 1 | 0 |
| 1 | 0 | 0 | 1 |
| 0 | 1 | 0 | 1 |
Solution

Since the sum of the numbers in all the cells of the board is 8, the sum of the numbers in each row and column is $8 / 4=2$. That is, in each row and column, there are exactly two digits equal to 1 and two digits equal to 0. We can choose the position of the first 1 in the first row in 4 ways. Then, we can choose the position of the second 1 in 4-1 = 3 ways, as we cannot place it in an already chosen position. However, in these $3 \cdot 4$ choices, we are counting each way of placing them in the first row twice, because as they are identical digits, reversing their positions generates the same choice. Therefore, we have $3 \cdot 4 / 2=6$ ways to arrange the two digits 1 in the first row. After making this choice, we have three cases to consider for the second row: (I) all its digits are the same as those in the corresponding positions in the first row, (II) all the digits in the second row differ from their corresponding ones in the first row, and (III) two digits in the second row coincide with their corresponding ones in the first row. There are no other cases, because if three digits in the third row coincide with their corresponding ones in the first, as only two digits of each type appear in it, the fourth digit will necessarily be the same. Similarly, we can also see that it is not possible for only one digit to coincide between the first two rows.

![](https://cdn.mathpix.com/cropped/2024_05_01_82072e76ed187b592b1cg-21.jpg?height=225&width=209&top_left_y=1209&top_left_x=636)

Case I

![](https://cdn.mathpix.com/cropped/2024_05_01_82072e76ed187b592b1cg-21.jpg?height=225&width=196&top_left_y=1209&top_left_x=1031)

Case II

![](https://cdn.mathpix.com/cropped/2024_05_01_82072e76ed187b592b1cg-21.jpg?height=225&width=199&top_left_y=1209&top_left_x=1418)

Case III

The total number of boards in case (I) is equal to the number of possible choices for the first row, which is 6. In case (II), the two first rows differ in all positions. For the choice of the third row, we can determine the positions of the two digits equal to 1 in 6 ways, and the remaining positions will be filled with 0. Then, the fourth row can only be chosen in one way, as the first three digits of each column will already have been defined. In this case, we have 6 possible choices for the first row and another 6 for the second row. This gives a total of $6 \cdot 6=36$ possibilities.

![](https://cdn.mathpix.com/cropped/2024_05_01_82072e76ed187b592b1cg-21.jpg?height=219&width=490&top_left_y=1942&top_left_x=860)

In case (III), we have 6 possible choices for the first row. After making this choice, we can choose in 2 ways which of the positions in the second row will repeat the digit 1 from the first row and in another 2 ways which of the positions in the second row will repeat the digit 0. This gives us $6 \cdot 2 \cdot 2=24$ fillings of the first two rows. In the cells of these two rows, in precisely two columns, we will have already written 2 digits equal to 1 and two digits equal to 0. Consequently, the remaining cells in these columns will be determined. Still analyzing the possible choices for the third row, we have 2 possible choices for the leftmost cell not yet filled. Once it has been chosen, the entire third row will be determined, and finally, the digits in the fourth row as well.

| 1 | 1 | 0 | 0 |
| :--- | :--- | :--- | :--- |
| 0 | 1 | 1 | 0 |
|  |  |  |  |
|  |  |  |  |$\rightarrow$| 1 | 1 | 0 | 0 |
| :--- | :--- | :--- | :--- | :--- |
| 0 | 1 | 1 | 0 |
|  | 0 |  | 1 |
|  | 0 |  | 1 |

Therefore, in this case, we have $24 \cdot 2=48$ possible boards. Adding the configurations found in the three situations, we have $6+36+48=90$ possibilities of arranging the digits on the board.