N Queens by moriA

main=do n<-readLn;mapM(putStrLn.unwords.map show)$[[]]#[1..n]!!n
s#t=s:[a:b|a+1<-t,b<-s,and[d^3/=c^2*d|(c,d)<-zip t$map(a-)b]]#t

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

download

return to the top page