% Filename: knight.mzn % % Usage: % $ minizinc knight.mzn -a --soln-sep "" --search-complete-msg "" -D"s=2;r=3" -D "n=10" | awk 'NF' | sort % % See also: http://www.minizinc.org % int: n; int: s; int: r; array[int,int] of int: move = [|0,0|s,-r|s,r|r,-s|r, s|]; int: zidx = 1; constraint assert(0 < s /\ s <= r, "invalid parameters"); array[1..n] of var index_set_1of2(move): x; array[1..n+1] of var int: h; constraint h[1] == 0 /\ h[n+1] == 0; constraint forall([h[i] >= 0 | i in 1..n+1]); constraint forall([h[i+1] - h[i] == move[x[i],2] | i in 1..n]); constraint forall([x[i] == zidx -> x[i+1] == zidx | i in 1..n-1]); constraint sum([move[x[i],1] | i in 1..n]) == n; solve satisfy; output [if fix(x[i]) != zidx then show(x[i]) ++ " " else "" endif | i in 1..n]