# Greeks and Romans and cards

Take the aces and face cards from a deck; you can arrange those sixteen cards in a square. But can you arrange them in a square in such a way that every rank and every suit appears in every row, every column, and both diagonals? You can. (Go try it, it’s not that hard.) How many ways? (That’s harder!)

A simpler problem is to ignore the suits and just have every row, column, and diagonal contain all four ranks. You can do that easily enough by trial and error, but how many ways can you do it?

Let’s suppose you make the top row A K Q J and see what solutions that leads to. Every other row, column, and diagonal has to be some permutation of A K Q J. In particular, the first column must be one of the permutations that begins with A. There are six such permutations:

```A K Q J
A K J Q
A Q K J
A Q J K
A J K Q
A J Q K```

But it can’t be A K Q J or A Q K J, because that would put two Js on one of the diagonals. So for the first row and column there are four possibilities:

```A K Q J   A K Q J   A K Q J   A K Q J
K         Q         J         J
J         J         K         Q
Q         K         Q         K```

Now, what goes in the third row, third column for the first of these? It shares a diagonal with an A, a row with a J, and a column with a Q, so it has to be a K:

```A K Q J
K
J   K
Q     ?```

Now what do you put in the fourth row, fourth column? Not an A or a K, because it shares a diagonal with them; not a Q, because it shares a row with that, and not a J, because it shares a column with that. There’s nothing you can put there. So the first column can’t be A K J Q.

In similar fashion you can eliminate A J Q K. The second row, second column must be Q, and then once again the fourth row, fourth column can’t be filled.

Try the second possibility:

```A K Q J
Q ?
J   ?
K     ?```

The second row, second column has to be a J; the third row, third column must be a K; and the fourth row, fourth column is a Q.

```A K Q J
Q J
J   K
K     Q```

Then the remaining positions are similarly forced: A in row 2, column 3; then K in row 2, column 4; then A in row 3, column 4, and so on:

```A K Q J
Q J A K
J Q K A
K A J Q```

Likewise the third possibility allows only one completion:

```A K Q J
J Q K A
K A J Q
Q J A K```

So that’s it, those are the only two ways to do it with A K Q J in the first row. Any other solution then will have to be what you get if you take one of the A-K-Q-J solutions and permute the ranks. There are 24 such permutations, so there are 48 solutions.

This is an example of a Latin square. In fact the requirement that the diagonals contain all four suits is extra. A Latin square needs only to have all four in each row and column. Or all five or whatever — you can do Latin squares of any size.

Now if you pay attention to both rank and suit, and require each row and each column to contain all four of each, that’s a Graeco-Latin square. Again, that says nothing about the diagonals, but you can extend the requirement to them and still get solutions for squares of size 4.

The ranks have to form a Latin square and so do the suits. Replace A, K, Q, J with H, C, D, S (hearts, clubs, diamonds, spades) in the above squares and those are your possibilities for the suits. There are just two that have H, C, D, S in the top row:

```H C D S   H C D S
D S H C   S D C H
S D C H   C H S D
C H S D   D S H C```

But you can’t use the first possibility for both the ranks and the suits. Otherwise all the As will be Hs, all the Ks will be Cs, and so on. Likewise you can’t use the second possibility for both. But you can use the first for one and the second for the other, either way around:

```AH KC QD JS   AH KC QD JS
QS JD AC KH   JD QS KH AC