N Queens by fox

main=do n<-readLn;mapM_(putStrLn.unwords.map show)$n#n
0#_=[[]]
m#n=[k:l|k<-[0..n-1],l<-(m-1)#n,all(k/=)$zip[1..]l>>=g]
g(x,y)=[y,y-x,y+x]

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

download

return to the top page