4

I need help with algorithm, which creates all Latin squares up to n=10. I am in the point, when i have created n! Latin squares and I have tried to permute rows and columns afterwards, so it gave me n!*n!*n! Latin squares, but according to wikipedia(https://en.wikipedia.org/wiki/Latin_square) this extension of n! Latin squares is wrong. Don't have anyone any idea how to get all possible Latin Squares?

Cœur
  • 37,241
  • 25
  • 195
  • 267
preneond
  • 497
  • 2
  • 5
  • 21

1 Answers1

3

Your effort is, alas, doomed. We still don't know a formula for calculating the number of Latin squares of size n. However, someone poor soul did work it out for n=10. Whilst generating the squares is possible (you can always just generate all possibilities, and see if they're a latin square), you're going to get

9,982,437,658,213,039,871,725,064,756,920,320,000

answers (Wikipedia).

So, I hope you've got a big hard disk and a lot of time.

Adam Wright
  • 48,938
  • 12
  • 131
  • 152
  • I formulated my question little bit wrong.We are trying to write an algorithm which can create as many Latin squares as it can. Latin square has side n=1,2,...10. To n=6 the number is not so high(according to sheet on wikipedia) – preneond Feb 29 '16 at 11:29
  • @prone666 : What do you mean by 'as many Latin square as it can' - in some fixed time? You might also see this : http://math.stackexchange.com/questions/145228/formula-for-the-number-of-latin-squares-of-size-n – gilleain Feb 29 '16 at 13:39
  • Better check this one too http://math.stackexchange.com/questions/63131/generate-random-latin-squares – cpicanco Feb 29 '16 at 20:10