Latin Square Generator

Each symbol once per row & column

CalculatorsFreeNo Signup
4.6(291 reviews)
All Tools

Loading tool...

About Latin Square Generator

A Latin square generator creating n×n arrays filled with n different symbols, each occurring exactly once per row and once per column. Shows construction methods, checks validity, and counts Latin squares. Related to Sudoku and experimental design. Client-side.

Latin Square Generator Features

  • Generation
  • Validity check
  • Reduced form
  • Count
  • Orthogonal pairs
Latin square: n×n grid with n symbols, each appearing once per row and column. Order 3: 3 symbols, 12 Latin squares (1 reduced). Applications: experimental design (agriculture, medicine), Sudoku (9×9 Latin square with box constraint), error-correcting codes, and finite geometry.

How to Use

Enter n:

  • Generate: Random Latin square
  • Reduced: First row/column in order
  • Verify: Check validity

Counting

L(n) grows super-exponentially: L(1)=1, L(2)=2, L(3)=12, L(4)=576, L(5)=161280, L(6)=812851200... No closed form exists. Computing L(n) is #P-complete for general n.

Applications

  • Experimental design: balance treatments across conditions
  • Sudoku: Latin square + box constraint
  • Coding theory: orthogonal Latin squares → error-correcting codes
  • Tournament scheduling

Step-by-Step Instructions

  1. 1Choose order n.
  2. 2Generate square.
  3. 3Verify validity.
  4. 4View reduced form.
  5. 5Check count.

Latin Square Generator — Frequently Asked Questions

How are Latin squares related to Sudoku?+

A Sudoku grid IS a 9×9 Latin square (each digit 1-9 once per row and column) with the added constraint that each 3×3 box also contains all digits. So Sudoku is a special case of Latin square.

What are orthogonal Latin squares?+

Two n×n Latin squares are orthogonal if, when superimposed, every ordered pair of symbols appears exactly once. Euler conjectured none exist for n≡2 (mod 4), but this was disproven for all n>6. Only n=2 and n=6 have no orthogonal pairs.

How to construct a Latin square easily?+

Cyclic construction: row i has symbols (i, i+1, i+2, ..., i+n-1) mod n. This always works! For n=4: row 0 = [0,1,2,3], row 1 = [1,2,3,0], row 2 = [2,3,0,1], row 3 = [3,0,1,2].

Share this tool: