Search for a tool
Latin Square

Tool to create or solve Latin squares, a square grid of NxN with N distinct symbols distributed without repetition in each row and column, ideal for lovers of logic and puzzles similar to sudoku.

Results

Latin Square -

Tag(s) : Number Games

Share
Share
dCode and more

dCode is free and its tools are a valuable help in games, maths, geocaching, puzzles and problems to solve every day!
A suggestion ? a feedback ? a bug ? an idea ? Write to dCode!


Please, check our dCode Discord community for help requests!
NB: for encrypted messages, test our automatic cipher identifier!


Feedback and suggestions are welcome so that dCode offers the best 'Latin Square' tool for free! Thank you!

Latin Square

Latin Square Solver

Loading...
(if this message do not disappear, try to refresh this page)

See also: Sudoku Solver

Latin Square Generator




See also: Sudoku Solver

Answers to Questions (FAQ)

What is a latin square? (Definition)

A Latin square is a square grid of size $ n \times n $ filled with $ n $ distinct symbols (letters, numbers, or others). The main rule is as follows: each symbol must appear exactly once in each row and exactly once in each column.

Example: A 3x3 Latin square using the symbols $ 1,2,3 $:

123
312
231

How to generate a latin square?

There are several methods for generating Latin squares. Here is the shortest to explain:

1- Take an empty NxN grid,

Example:

---
---
---

2- Fill the first row with N symbols

Example:

ABC
---
---

3- Fill the next row by shifting all the symbols by 1 box to the right (and return to the beginning of the row if necessary)

Example:

ABC
CAB
---

4- Repeat step 3 until you reach the last row of the grid.

Example:

ABC
CAB
BCA

And voilĂ ! The square is thus valid but always identical, to obtain others:

5- Randomly swap 2 rows

6- Randomly swap 2 columns

7- Repeat steps 5 and 6 as many times as desired, the result is always a Latin square.

There are variants of Latin squares with additional constraints, such as diagonal Latin squares where each symbol must also be unique on both long diagonals of the grid.

How to solve a latin square?

Solving a Latin square can be summarized in one loop:

1- For each empty cell, determine the symbols that are not already present in the row and column.

2- If only one symbol is possible, the cell can be filled immediately with that symbol.

3- Repeat step 1 until the grid is complete.

For more complex grids, algorithmic methods are used, such as backtracking, which tests different possibilities while respecting the constraints.

Why is a Latin square so called?

The term Latin square was introduced by the Swiss mathematician Leonhard Euler in the 18th century. In his work, Euler used letters of the Latin alphabet as symbols to fill the grids.

What is the the thirty-six officers problem?

The 36 Officers Problem, posed by Euler in 1782, asks whether it is possible to arrange 36 officers belonging to 6 different regiments and 6 different ranks in a 6 Ă— 6 grid such that each row and each column contains every regiment and every rank exactly once. This problem is equivalent to finding two orthogonal Latin squares of order 6 (also called Graeco-Latin squares). It was proven in the 20th century that such a configuration is impossible.

What are the variants of the latin square?

The best known variant is sudoku, which uses the same bases, but adds a constraint on blocks of 3x3 (and sometimes other constraints for irregular sudoku).

Ken-ken (kendoku) is also a Latin square with constraints of mathematical calculations.

The magic square is a distant mathematical variant which takes up the fact that the sum of the rows and the columns is always identical, but it is not limited to N distinct symbols.

How many different Latin squares exist for a given size?

The number of possible Latin squares increases rapidly with the size of $ N $. For $ N = 3 $ there are 12 different Latin squares, for $ N = 4 $ there are 576, then 161280 for 5, 812851200 for 6 etc. for larger sizes this number becomes exponential, see here

There is currently no simple formula that allows this number to be calculated directly for any $ N $.

When was the Latin square invented?

Latin squares were systematically studied by the mathematician Leonhard Euler in 1782 (18th century). However, similar structures were probably used long before.

Source code

dCode retains ownership of the "Latin Square" source code. Any algorithm for the "Latin Square" algorithm, applet or snippet or script (converter, solver, encryption / decryption, encoding / decoding, ciphering / deciphering, breaker, translator), or any "Latin Square" functions (calculate, convert, solve, decrypt / encrypt, decipher / cipher, decode / encode, translate) written in any informatic language (Python, Java, PHP, C#, Javascript, Matlab, etc.) or any database download or API access for "Latin Square" or any other element are not public (except explicit open source licence). Same with the download for offline use on PC, mobile, tablet, iPhone or Android app.
Reminder: dCode is an educational and teaching resource, accessible online for free and for everyone.

Cite dCode

The content of the page "Latin Square" and its results may be freely copied and reused, including for commercial purposes, provided that dCode.fr is cited as the source (Creative Commons CC-BY free distribution license).

Exporting the results is free and can be done simply by clicking on the export icons ⤓ (.csv or .txt format) or ⧉ (copy and paste).

To cite dCode.fr on another website, use the link: https://www.dcode.fr/latin-square

In a scientific article or book, the recommended bibliographic citation is: Latin Square on dCode.fr [online website], retrieved on 2026-03-13, https://www.dcode.fr/latin-square

Need Help ?

Please, check our dCode Discord community for help requests!
NB: for encrypted messages, test our automatic cipher identifier!

Questions / Comments

Feedback and suggestions are welcome so that dCode offers the best 'Latin Square' tool for free! Thank you!


https://www.dcode.fr/latin-square
© 2026 dCode — The ultimate collection of tools for games, math, and puzzles.
â–˛  
Feedback