N Queens by xsd

open Array
let n=read_int()let
a,d=make n 0,iteri(fun i v->Printf.printf"%d%c"v"*
       ".[n-i])let
rec(@)x y=let rec($)y z=y<0||a.(y)!=x&abs(a.(y)-x)!=z&y-1$z+1in
y=n&()=d a||x<n&(y-1$1&(a.(y)<-x;0@y+1);x+1@y);;0@0

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

download

return to the top page