Questions tagged [latin-square]

Use this tag for programming questions about Latin squares. A Latin square is a N x N square array, populated with N distinct symbols. Each symbol occurs exactly once in each row, and it occurs exactly once in each column.

A Latin square is a N x N array filled with N distinct symbols. Each symbol appears exactly once in every row and exactly once in every column. This term was inspired by Leonhard Euler.

A reduced Latin square is one in which the symbols in the first row are in their natural order. The number of reduced Latin squares is thus fewer then the number of overall Latin squares, except for the trivial case N = 1.

The formula for computing the exact number of Latin squares for a size N is not easily computable.

Solutions to Sudoku puzzles are special cases of Latin squares.

Links

24 questions
4
votes
3 answers

Understanding this C function

I'm trying to understand how this function works, I have studied several algorithms to generate sudoku puzzles and found out this one. Tested the function and it does generates a valid 9x9 Latin Square (Sudoku) Grid. My problem is that I can't…
Zakri
  • 65
  • 1
  • 6
4
votes
1 answer

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…
preneond
  • 497
  • 2
  • 5
  • 21
4
votes
2 answers

Animate Javascript Canvas while in recursive calculation

I'm trying to animate a solution to the latin-square-problem in javascript. To do so, I wrote the recursive backtracking algorithm below. Solving the problem is initiated by calling search(0,0) and it works just fine, displaying a solution after…
dende
  • 119
  • 2
  • 8
3
votes
1 answer

How to generate a list of all distinct 3x3 Latin Square in Python

Latin Square is an nxn array filled with n different symbols, each occurring exactly once in each row and exactly once in each column (like sudoku). An example of Latin Square: 1 2 3 2 3 1 3 1 2 This is what I've tried, but it is still not all…
Vince
  • 33
  • 2
  • 5
3
votes
3 answers

Prolog - Latin Square solution

I am trying to write a program in Prolog to find a Latin Square of size N. I have this right now: delete(X, [X|T], T). delete(X, [H|T], [H|S]) :- delete(X, T, S). permutation([], []). permutation([H|T], R) :- permutation(T, X), delete(H,…
Izabela
  • 333
  • 1
  • 3
  • 15
3
votes
4 answers

Filling a 2D array with randomised numbers

I have started a project trying to create a Ken Ken puzzle. If you are not sure what Ken Ken is, it is similar to Sudoku in the way that there can be no duplicated integer values in a row or column. I am trying to fill a 2D Array with numbers from…
Jordan King
  • 93
  • 1
  • 6
2
votes
2 answers

Java: Contiguous region in a multi-dimensional array, used to implement a Latin Square

I am writing a program that reads in a potential Latin Square and tells whether or not it is a valid latin square or not. Now I am trying tell if the region selected is a contiguous one or not. The potential Latin Square and the location of the…
2
votes
0 answers

Creating an efficient local search technique in Python for Latin Squares

I am basically needing to create a local search technique using the cost function. I need to create a new function that randomly swaps the original solution in the latin square, then calculates the cost and if it is better than the original…
JamieNorth
  • 21
  • 2
2
votes
2 answers

Making a latin square

Im trying to get a question done for some school homework, and im just having the worst case of brain farts humanity has ever seen. The the question asks for three things. • It reads a number N on a line by itself. This will be the order of a Latin…
2
votes
5 answers

Creating a Latin Square program in Python

order = input("Input the order of a Latin Square: ") top_left = input("Input the top-left number: ") int_order = int(order) int_top_left = int(top_left) for order in range(int_order): for top_left in range(int_order): print(int_top_left,…
Bailey Labadie
  • 21
  • 1
  • 1
  • 2
2
votes
1 answer

Experimental design in R: balanced incomplete block design

I would like to generate a matrix to plan an experiment. I have 6 individuals and 6 treatments delivered in 6 days. I can use 1 individual per week (6 weeks of 6 days in total = 36 days of testings with 6 treatments a day). Every day, I will test…
user3406207
  • 315
  • 1
  • 3
  • 18
1
vote
4 answers

Generating Random Latin Square Continuous Loop

I'm working on a program to generate random grids, latin squares, and sudoku. I am working on the latin squares and pretty much have it all working except I am in a continuous loop. If I break them up they work fine. There is probably something…
1
vote
1 answer

Enforce "sudoku-like" (latin square) constraint on radio buttons

In my GUI, I need a 3x3 array of radio-buttons, constrained so that only one can be selected in each row, and only one can be selected in each column. Is this possible client-side, without Javascript (I'm happy to use javascript, but would like a…
Chowlett
  • 45,935
  • 20
  • 116
  • 150
1
vote
0 answers

DAG algorithms and Latin square problems

Every Latin square corresponds to a directed acyclic graph with a lattice arrangement, and whose edges indicate order (<). For example: (source: enjoysudoku.com) I'm interested in determining which Latin squares have unique orderings, that is,…
Jim White
  • 211
  • 1
  • 6
1
vote
2 answers

Replicated Latin Square Analysis in R Language with ANOVA

I am executing a 1 factor(tool) experiment with 2 treatments and 2 block variables (participant and process). In other words, a 2x2 Latin square. One of the block variables is the participants. As my sample has 8 participants, I have 4 2x2 latin…
csfb
  • 1,105
  • 1
  • 9
  • 19
1
2