class Array def rot push( shift ) end end proc{|n| p ((1..n).partition{|x|x%2>0}.inject{|o,e| e + case n % 12 when 2 [3,1]+o[3..-1]+[5] when 3,9 o.rot.rot;e.rot;o when 8 d=-2;o.map{|x| x + d*=-1} end})}[ 8 ]
(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))))
-----
else o