3. In each cell of a $4 \times 4$ square table, the digit 1 or the digit 2 is written. It is known that the sum of the 9 digits contained in each of the 4 $3 \times 3$ squares contained in the table is a multiple of 4, while the sum of all 16 digits is not a multiple of 4.

Determine the maximum and minimum possible value for the sum of all 16 digits.
Solution: The maximum and minimum are, respectively, 30 and 19 and are achieved, for example, by the following tables

| 2 | 2 | 2 | 2 |
| :--- | :--- | :--- | :--- |
| 2 | 2 | 1 | 2 |
| 2 | 1 | 2 | 2 |
| 2 | 2 | 2 | 2 |


| 1 | 1 | 1 | 1 |
| :--- | :--- | :--- | :--- |
| 1 | 2 | 2 | 1 |
| 1 | 2 | 1 | 1 |
| 1 | 1 | 1 | 1 |

Indeed, for the sum of the 9 digits in a $3 \times 3$ square to be divisible by 4, there are only two possibilities: having 6 times the digit 1 and 3 times the digit 2 (sum 12), or having 2 times the digit 1 and 7 times the digit 2 (sum 16).

It is therefore clear that in the $4 \times 4$ table, there are at least 2 digits 1. If we place them, in any way, within the central $2 \times 2$ square of the table, so that they are contained in all 4 $3 \times 3$ squares, no more digits 1 are needed. The maximum sum is thus achieved with 2 digits 1 and 14 digits 2, for a total of 30.

Similarly, in the $4 \times 4$ table, there are at least 3 digits 2, and no more are needed if these are placed, in any way, within the central $2 \times 2$ square of the table. The minimum sum is thus achieved with 3 digits 2 and 13 digits 1, for a total of 19.