N Queens by pooq

var m:comp;b:array[0..7]of word;procedure f(n:word);var i,j,k,c:comp;label 1;begin
for i:=0to m-1do
begin
for j:=0to n-1do
begin
c:=b[j];if(c=i)or(j-c=n-i)or(j+c=n+i)then goto 1end;b[n]:=i;if n=m-1then begin for k:=0to m-1do write(^`:ord(k>0),b[k]);writeln;goto 1end;f(n+1);1:end
end;begin
read(m);f(0)end.

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return to the top page