Arc Forumnew | comments | leaders | submitlogin
1 point by map 6136 days ago | link | parent

  (def valid? (stack)
    (let i 0
      (if (or (pos stack.0 cdr.stack)
              (some [is ++.i (abs:- stack.0 _)] cdr.stack))
        nil
        t)))

  (def queens (stack n)
    (if (is n 8)
      (do (prall rev.stack "[ ") (prn " ]"))
      (for rank 1 8
        (push rank stack)
        (if (valid? stack)
            (queens stack (+ n 1)))
        (pop stack))))

  (queens '() 0)