How many ways to colour a $4 \times 4$ grid using four colours subject to three constraints
In how many ways can a $4 \times 4$ square grid be coloured using four different colours so that no colour is repeated in any row, column, or along the two main diagonals. For clarity, one valid solution to this problem is shown below.
I am after unique solutions, so:
- rotations of the grid through angles of $90^\circ, 180^\circ$, and $270^\circ$, and
- reflections about the horizontal, vertical, and the two main diagonals
are not considered different.
I am guessing this problem is perhaps well known, so I apologise in advance, but have not been able to make much progress towards its solution. It may even go by a well known name, making it easier to identify, and if this is indeed the case I would be interested in knowing what it is called.
Your requirements for the placement of colors is equivalent to the requirements for a diagonal Latin square, or as it used to be called, a double diagonal Latin square. According to OEIS, there are just $48$ diagonal Latin squares of order $4$, i.e. of size $4$ x $4$.
As @Arthur pointed out, if rotations and reflections are not considered distinct, we must divide this number by $8$. Hence, there are just $6$ distinct solutions.
EDIT
Just made a brute force program to check that I was right, and it gave the answer $12$, not $6$. Manual checking of the program's answer seems to show the program is correct. Here is the program's answer:
None of these appear to be rotations or reflections of each other. What did I miss?
EDIT 2
As @omegadot points out, the solutions above include reflections about the main diagonals. Removing these cases gives the following: