1
0
This repository has been archived on 2025-03-06. You can view files and clone it, but cannot push or open issues or pull requests.

19 lines
627 B
MiniZinc

int: n; % size of latin square
array[1..n,1..n,1..n] of var bool: a;
predicate atmostone(array[int] of var bool:x) =
forall(i,j in index_set(x) where i < j)(
(not x[i] \/ not x[j]));
predicate exactlyone(array[int] of var bool:x) =
atmostone(x) /\ exists(x);
constraint forall(i,j in 1..n)(
exactlyone(k in 1..n)(a[i,j,k]) /\
exactlyone(k in 1..n)(a[i,k,j]) /\
exactlyone(k in 1..n)(a[k,i,j])
);
solve satisfy;
output [ if fix(a[i,j,k]) then
show(k) ++ if j == n then "\n" else " " endif
else "" endif | i,j,k in 1..n ];