Data Update
This commit is contained in:
parent
015c2add84
commit
e50b5c3114
206 changed files with 6337 additions and 523 deletions
12
Task/N-queens-problem/Maxima/n-queens-problem-2.maxima
Normal file
12
Task/N-queens-problem/Maxima/n-queens-problem-2.maxima
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
/* 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(%);
|
||||
Loading…
Add table
Add a link
Reference in a new issue