Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
19
Task/N-queens-problem/Pure/n-queens-problem.pure
Normal file
19
Task/N-queens-problem/Pure/n-queens-problem.pure
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
/*
|
||||
n-queens.pure
|
||||
Tectonics:
|
||||
pure -c queens.pure -o queens
|
||||
or
|
||||
pure -q -i queens.pure
|
||||
*/
|
||||
using system;
|
||||
|
||||
queens n = search n 1 [] with
|
||||
search n i p = [reverse p] if i>n;
|
||||
= cat [search n (i+1) ((i,j):p) | j = 1..n; safe (i,j) p];
|
||||
safe (i,j) p = ~any (check (i,j)) p;
|
||||
check (i1,j1) (i2,j2)
|
||||
= i1==i2 || j1==j2 || i1+j1==i2+j2 || i1-j1==i2-j2;
|
||||
end;
|
||||
|
||||
compiling || (puts("queens 4: " + str(queens 4)) $$
|
||||
puts("Solutions to queens 7: " + str(#queens 7)));
|
||||
Loading…
Add table
Add a link
Reference in a new issue