preneond
preneond

Reputation: 531

Algorithm which creates all possible Latin squares

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?

Upvotes: 5

Views: 2681

Answers (1)

Adam Wright
Adam Wright

Reputation: 49376

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.

Upvotes: 3

Related Questions