N-queens solved entirely in Python type annotations with ty, each solution a tuple

charliermarsh · x · 2026-10-28

Charlie Marsh (Astral) shared an N-queens solver written purely in Python type annotations, powered by the ty type checker. There is no runtime logic — the search happens entirely at the type level, supporting arbitrary Peano-encoded board sizes, with each tuple in the revealed type representing one valid solution. The full 45-line implementation showcases ty's inference on deep recursive types.

Original post →

More from coding & agent

coding & agent channel →