Talk:Random Latin squares
Python Algorithm
I got the mention of Latin squares from a stack-overflow question and a link to some solution methods that I did not read (and so did not add to the task as a reference).
I worked out that if you have a smaller solution of:
0 1 1 0
then the next larger solution (ignoring randomisation), could be got by: 1. Insert a copy of the first row at the end:
0 1 1 0 0 1
2. Insert the new symbol along the diagonal
2 0 1 1 2 0 0 1 2
I randomise the selection of symbol to insert at each recursive stage, and at the end swap rows randomly and swap columns randomly as these transformations preserve "Latin-ness".
If you read the reference mentioned in the first sentence and think it is of use, then please add it to the task.