(def rot ((x . y)) (join y `(,x))) (def nqueens (n) (withs (r (range 1 n) o (keep odd r) e (keep even r) m (mod n 12)) (join (if (pos m '(3 9))(or wipe.m rot.e) e) (case m 2 (flat:list 3 1 (cut o 3 -1) 5) 8 (flat:map rev pair.o) nil (rot:rot o) o))))
Edit: using "flat:list" for case 2.
Edit: replaced (wipe m) with wipe.m, etc.