tasks a-s
This commit is contained in:
parent
47bf37c096
commit
b83f433714
12433 changed files with 156208 additions and 123 deletions
17
Task/N-queens-problem/Logo/n-queens-problem.logo
Normal file
17
Task/N-queens-problem/Logo/n-queens-problem.logo
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
to try :files :diag1 :diag2 :tried
|
||||
if :files = 0 [make "solutions :solutions+1 show :tried stop]
|
||||
localmake "safe (bitand :files :diag1 :diag2)
|
||||
until [:safe = 0] [
|
||||
localmake "f bitnot bitand :safe minus :safe
|
||||
try bitand :files :f ashift bitand :diag1 :f -1 (ashift bitand :diag2 :f 1)+1 fput bitnot :f :tried
|
||||
localmake "safe bitand :safe :safe-1
|
||||
]
|
||||
end
|
||||
|
||||
to queens :n
|
||||
make "solutions 0
|
||||
try (lshift 1 :n)-1 -1 -1 []
|
||||
output :solutions
|
||||
end
|
||||
|
||||
print queens 8 ; 92
|
||||
Loading…
Add table
Add a link
Reference in a new issue