A Latin Square is pandiagonal if every left and right diagonal also has distinct digits. Here is an example (N = 7):

- Code: Select all
`+---+---+---+---+---+---+---+`

| 1 | 5 | 3 | 4 | 6 | 7 | 2 |

+---+---+---+---+---+---+---+

| 3 | 4 | 6 | 7 | 2 | 1 | 5 |

+---+---+---+---+---+---+---+

| 6 | 7 | 2 | 1 | 5 | 3 | 4 |

+---+---+---+---+---+---+---+

| 2 | 1 | 5 | 3 | 4 | 6 | 7 |

+---+---+---+---+---+---+---+

| 5 | 3 | 4 | 6 | 7 | 2 | 1 |

+---+---+---+---+---+---+---+

| 4 | 6 | 7 | 2 | 1 | 5 | 3 |

+---+---+---+---+---+---+---+

| 7 | 2 | 1 | 5 | 3 | 4 | 6 |

+---+---+---+---+---+---+---+

Note that we generalise the idea of a diagonal by allowing "wraparound". These are also called broken diagonals. Thus there are N left diagonals and N right diagonals. For N = 5, the left diagonals are:

- Code: Select all
`X . . . . . X . . . . . X . . . . . X . . . . . X`

. . . . X X . . . . . X . . . . . X . . . . . X .

. . . X . . . . . X X . . . . . X . . . . . X . .

. . X . . . . . X . . . . . X X . . . . . X . . .

. X . . . . . X . . . . . X . . . . . X X . . . .

So a PD latin square is essentially a 4-house "Sudoku Variant". The grid can be partitioned into sets of N houses, one set each for rows, cols, left diagonals, right diagonals.

Unfortunately, PD Latin squares are very rare. They can only occur when N is not divisible by 2 or 3. For N = 5, 7, and 11 there are very few (2, 4 and 8 respectively), and they are all cyclic, which means each row/col is a cyclic shift of the first row/col.

However, for N = 13, it suddenly gets interesting. There are 12,386 ED grids, most (90%) of them being non-cyclic, so suitable for puzzle creation.

For N > 13 (N = 17, 19, 23, 25 etc), the number of grids expands, but enumerating them becomes computationally difficult. The "disjoint template" method can quickly find all N=13 grids, but N=17 is very much harder.

N = 13 also seems to be a good size for P&P solving (not too unwieldy) ...

Here is an example grid for N =13. I use {1-9,ABCD} to represent the digits 1 to 13:

**Pandiagonal LS, N=13:**Show