Why hand-rolling a backtracking solver for a corn puzzle was a mistake

Solving a corn puzzle with CP-SAT

At a Recurse Center Friday, the author faced a 3D-printed corn puzzle and asked Claude to solve it. Claude's Python script used Google's OR-Tools CP-SAT instead of recursive backtracking, modeling the exact cover problem with binary variables and constraints. The author then applied CP-SAT to Sudoku with friends, learning to reach for solvers rather than reinvent the wheel.

when I get another cp-sat shaped problem in the future, I'll know to try a solver and read the docs for whatever else I need, rather than roll my own.
  1. emil-lp

    CP here being Constraint Problem, or CSP (Constraint Satisfaction Problem).

    https://en.wikipedia.org/wiki/Constraint_satisfaction_proble...

  2. sashank_1509

    Ok, in this specific case, a puzzle with what 10 pieces, a recursive backtracker will be just as fast and more importantly, be far easier to reason about and implement.

    If this was a thousand piece puzzle, I would still venture recursive backtracker with good heuristics will beat CP-SAT, even in the sudoku case some good heuristics with backtracking beats CP-SAT. Not sure why Claude immediately jumped to using CP-SAT.

  3. nh23423fefe

    > It was much better than I would have written myself, and I ended up learning from it.

    Eventually shitting on LLM code will be seen by all as lazy cope. I too am aware of the existence of SAT but I really would struggle to immediately see through some problem i was having and interpret SAT unless I did it a bunch. Having agent suggest the "right thing" is clearly better. And hopefully would help my intuition in the future.

More from this day

2026-09-28