Att vara n-queens

MiniZinc model

include "globals.mzn";
int: n;
array[1..n] of var 1..n: x;
array[1..n] of string: s; 
solve satisfy;
constraint all_different(x);
constraint all_different([x[i]+i | i in 1..n]);
constraint all_different([x[i]-i | i in 1..n]);
output 
[ 
  if i = 1 then "<li> " else "" endif ++
  show(s[fix(x[i])])++ " "
  | i in 1..n
];

n = 8;
s = ["att","vara","eller","inte","vara","det","är","frågan"];

Back to Constrained-based constraint poetry
Created by Hakan Kjellerstrand hakank@gmail.com