(def rot ((x . y)) (join y `(,x))) (def nqueens (n) (withs (m (mod n 12) r (range 1 n) od (keep odd r) cod (cddr od) s '(1 3) ev (keep even r)) (if (join (pos m '(3 9)) (rot ev) (join cod s)) (join ev (case m 8 (apply join (map rev (pair od))) 2 (join (rev s) (rot cod)) od)))))
(def rot ((x . y)) (join y `(,x))) (def nqueens (n) (withs ((od ev) (part odd (range 1 n)) cod (cddr od) s '(1 3)) (join ev (case (mod n 12) 8 (apply join (map rev (pair od))) 2 (join (rev s) (rot cod)) 3, 9 (do (zap (rot ev)) (join cod s)) od))))