[Math] How many ways are there to color $1\times1$ squares in a $4\times5$ rectangle

combinatorics

How many ways are there to color $1\times1$ squares in a $4\times5$ rectangle with four colors in a way that every $2\times2$ square contains all four colors?

The answer to this is very simple but needs to prove sth that I can't. The following statement:

In every coloring we use two colors repeatedly in a column or row I mean like below here is the column case:

enter image description here

Any hints?

Best Answer

Let's consider separately cases where there are $4,2$ and $3$ different colours in the first column.

Case 1:

$4$ different colors. This has only one pattern since the outermost colors must switch places with the center two colors and there is only one way this can happen. Colors can be chosen in $4!=24$ different ways. $$\begin{bmatrix}a&c&a&c&a\\b&d&b&d&b\\c&a&c&a&c\\d&b&d&b&d\end{bmatrix}$$

Case 2:

$2$ different colors. First column can be constructed in $4\cdot3=12$ ways. There can only be $2$ colors per column, but for every column from $2$ to $5$ there are two possible arrangements. In total there are $12\cdot2^4=192$ solutions.

$$\begin{bmatrix}a&c&a&c&a\\b&d&b&d&b\\a&c&a&c&a\\b&d&b&d&b\end{bmatrix}$$

Case 3:

3 different colors.

I) The first column can not be of the form $$\begin{bmatrix}a\\b\\c\\a \end{bmatrix}$$ (this would imply the two center colors would both be $d$)

II) If the same colors are arranged as follows there is only one pattern (since third row is fixed):

$$\begin{bmatrix}a&d&a&d&a\\b&c&b&c&b\\a&d&a&d&a\\c&b&c&b&c\end{bmatrix}$$

The colors can be chosen in $4\cdot3\cdot2=24$ ways.

III) The last possibility is case II) flipped. $24$ more combinations.

So in total there are $$24+192+2\cdot 24=264$$ ways color the squares such that the conditions are fulfilled.