Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
38
Task/N-queens-problem/Draco/n-queens-problem.draco
Normal file
38
Task/N-queens-problem/Draco/n-queens-problem.draco
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
byte SIZE = 8;
|
||||
word count;
|
||||
|
||||
proc solve([*] int hist; int col) void:
|
||||
int i, j, n;
|
||||
n := dim(hist, 1);
|
||||
if col = n then
|
||||
count := count + 1;
|
||||
writeln();
|
||||
writeln("No. ", count);
|
||||
writeln("-----");
|
||||
for i from 0 upto n-1 do
|
||||
for j from 0 upto n-1 do
|
||||
write(if j=hist[i] then 'Q'
|
||||
elif (i+j)&1 /= 0 then ' '
|
||||
else '.' fi)
|
||||
od;
|
||||
writeln()
|
||||
od
|
||||
else
|
||||
for i from 0 upto n-1 do
|
||||
j := 0;
|
||||
while j<col and not (hist[j]=i or |(hist[j]-i) = col-j) do
|
||||
j := j + 1
|
||||
od;
|
||||
if j >= col then
|
||||
hist[col] := i;
|
||||
solve(hist, col+1)
|
||||
fi
|
||||
od
|
||||
fi
|
||||
corp
|
||||
|
||||
proc nonrec main() void:
|
||||
[SIZE] int hist;
|
||||
count := 0;
|
||||
solve(hist, 0)
|
||||
corp
|
||||
Loading…
Add table
Add a link
Reference in a new issue