12 lines
340 B
MiniZinc
12 lines
340 B
MiniZinc
int: n; % size of latin square
|
|
array[1..n,1..n] of var 1..n: a;
|
|
|
|
include "alldifferent.mzn";
|
|
constraint forall(i in 1..n)(
|
|
alldifferent(j in 1..n)(a[i,j]) /\
|
|
alldifferent(j in 1..n)(a[j,i])
|
|
);
|
|
solve satisfy;
|
|
output [ show(a[i,j]) ++ if j == n then "\n" else " " endif |
|
|
i in 1..n, j in 1..n ];
|