N Queens by notogawa

main=do n<-readLn;mapM(putStrLn.unwords.map show)$f[0..n-1]
f[]=[[]]
f x=[a:y|a<-x,y<-f[b|b<-x,b/=a],and$zipWith((/=).abs.(a-))y[1..]]

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

download

return to the top page