this repo has no description
1% latin_squares.mzn
2include "globals.mzn";
3
4int: n = 3;
5set of int: N = 1..n;
6array[N, N] of var N: X;
7
8constraint :: "ADRows"
9 forall (i in N)
10 (alldifferent(X[i,..]) :: "AD(row \(i))"
11 );
12constraint :: "ADCols"
13 forall (j in N)
14 (alldifferent(X[..,j]) :: "AD(col \(j))"
15 );
16
17constraint :: "LLRows"
18 forall (i in 1..n-1)
19 (lex_less(X[i,..], X[i+1,..]) :: "LL(rows \(i) \(i+1))"
20 );
21constraint :: "LGCols"
22 forall (j in 1..n-1)
23 (lex_greater(X[..,j], X[..,j+1]) :: "LG(cols \(j) \(j+1))"
24 );
25
26solve satisfy;
27
28output [ show2d(X) ];