3
$\begingroup$

How many 7 by 7 Latin squares are there, and how can one generate examples of them? I am working on classes for a game, and typing in numbers manually from 1-7 in rows and columns from scratch is exceedingly difficult. From what I can tell there are no generators for this type of thing online.

Yes I can type in 1-2-3-4-5-6-7, then the next row 3-4-5-6-7-1-2, but that does not work so well with stats of classes in a game.

Diagonals do NOT have to be 1-7. Rows and columns must have a unique number per square.

$\endgroup$
  • $\begingroup$ Please clarify your conditions on the square. Does every row and column have to contain each number 1 through 7 exactly once? And the diagonals too? $\endgroup$ – Lopsy Dec 21 '14 at 3:25
  • $\begingroup$ Only rows and columns. Sorry for the lack of information. $\endgroup$ – Dan Dec 21 '14 at 3:28
7
$\begingroup$

There are 61479419904000 seven by seven Latin squares. This is from OEIS, and hard to calculate in general.

If you just want to generate Latin squares quickly, you have a few options. One is quick and lazy: take a few template squares, and then generate more by permuting the rows, columns, and/or numbers. If you're comfortable with programming, you can write a quick backtracking solver. Or you could use this site. (Easy to Google once you know they're called, eh?)

$\endgroup$
0
$\begingroup$

Note that for any nxn, with n being odd, there's a trivial solution where even the diagonals work:

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

Just start with 1-n in the first column, and in each next column shift down 2 positions ('as the knight jumps', if you will).

That's however only a partial answer, on how you can generate an example. Given your intended purpose I think you're more looking into a 'randomlooking' example?

EDIT: Only after typing this up, I found it's covered in this question aswell, but in more detail.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.