Solutions to a Graeco-Latin grid?

156 Views Asked by At

I have a 4x4 grid of 16 different elements. Each element is composed of two numbers that can be 1-4. I want to know if I can find a permutation of the grid in which every row and column has 1-4 for each number. So if this were to be one of the rows:

(1,3), (4, 2), (3, 1), (2, 3)

Then it would have numbers 1-4 for the first number, but only 1, 2, and 3 for the second number. I have a program running on my computer that randomly shuffles the grid and tests it for the condition that I want. Is it possible to approach the problem logically such that I don't have to sift through 16^16 possible permutations?

1

There are 1 best solutions below

0
On BEST ANSWER

This is the problem of finding a Graeco-Latin square of order 4. Here is an example: $$\begin{bmatrix} 11&22&33&44\\ 34&43&12&21\\ 42&31&24&13\\ 23&14&41&32\end{bmatrix}$$ If we also require the diagonals to have numbers 1 to 4 for both first and second coordinates, then up to permuting numbers, rotations and reflections, there are only two solutions.