N Queens by test

main=readLn>>=mapM_(putStrLn.unwords.map show).f
f n=g n where g 0=[[]];g m=[i:j|i<-[0..n-1],j<-g$m-1,all(i/=)$zip[1..]j>>=h];h(p,q)=[q,q-p,q+p]

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

download

return to the top page