MathLabs

Problem 2

Find all integers nn for which each cell of an n×nn\times n table can be filled with one of the letters II, MM, and OO in such a way that: in each row and each column, one third of the entries are II, one third are MM, and one third are OO; and in any diagonal, if the number of entries on the diagonal is a multiple of three, then one third of the entries on that diagonal are II, one third are MM, and one third are OO. (Note that an n×nn\times n table has 4n−24n-2 diagonals in total, in both directions.)
Step 1 of 5: Construction: an explicit valid 9×99\times9 tile
In plain words

The following tile can be checked directly: every row, column, and diagonal whose length is a multiple of three has one third of each letter. Repeating the tile periodically gives every multiple of 99.

A valid 9×9 tile, repeated periodically\text{A valid }9\times9\text{ tile, repeated periodically}
Detailed analysis

Use the 9×99\times9 tile IOMOMIMOI IOMOIMOIM IMIMOMIOO OIOIOMMIM MOIIMOIOM MIMOIOOMI OIOMMIMIO MMOIIOOMI OMIMOIIMO. A direct count along the nine rows, nine columns, and every diagonal of length 33, 66, or 99 verifies the required one-third counts. Repeat this tile with period 99 in both directions. Any diagonal segment of length divisible by 33 then decomposes into complete three-step residue classes of the same periodic check, so it also has one third of each letter.