N-queens problem: Difference between revisions
Content added Content deleted
Line 8,847: | Line 8,847: | ||
...]] */ |
...]] */ |
||
length(%); /* 92 */</syntaxhighlight> |
length(%); /* 92 */</syntaxhighlight> |
||
<syntaxhighlight lang="maxima"> |
|||
/* Inspired by code from Python */ |
|||
Queens(N):=block([K,C,P,V,A,S,L:[]], |
|||
C: makelist(K,K,1,N), |
|||
P: permutations(C), |
|||
for V in P do ( |
|||
A: length(unique(makelist(V[K]+K, K, C))), |
|||
S: length(unique(makelist(V[K]-K, K, C))), |
|||
if is(A=N) and is(S=N) then L: cons(V, L) |
|||
), L |
|||
)$ |
|||
Queens(8);length(%);</syntaxhighlight> |
|||
=={{header|MiniZinc}}== |
=={{header|MiniZinc}}== |