N x n Matrix Puzzle

arithmeticpuzzle

You are given an n×n square matrix to be filled with numerals so that no two adjacent cells have the same numeral. Two cells are called adjacent if they touch each other horizontally, vertically or diagonally. So a cell in one of the four corners has three cells adjacent to it, and a cell in the first or last row or column which is not in the corner has five cells adjacent to it. Any other cell has eight cells adjacent to it.

What is the minimum number of different numerals needed to fill a 5×5 square matrix?

I tried, and I came up with the answer 5 but the answer that has been provided is 4. Can anyone please tell me how one can get to 4? What will be the arrangement?

Best Answer

Consider $$\begin{bmatrix} 0 &3 &0 &3 &0 \\ 2 &1 &2 &1 &2 \\ 0 &3 &0 &3 &0 \\ 2 &1 &2 &1 &2 \\ 0 &3 &0 &3 &0 \end{bmatrix}$$ which uses only $0,1,2,$ and $3$.

Related Question