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

Original title: Solving a corn puzzle with CP-SAT

> Hacker News story 49870760 · language: en · submitted 2026-09-27
> Web version: https://zeli.app/story/49870760
> About this feed: https://zeli.app/llms.txt · Agent guide: https://zeli.app/skill.md

▲ 32 · by [luu](<https://news.ycombinator.com/user?id=luu>) · 💬 16
[original](<https://thill.me/2026/07/16/corn-puzzle-sat-solver.html>) · [HN discussion](<https://news.ycombinator.com/item?id=49870760>)

## Summary

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.

## Key quote

> 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.

## HN discussion (16 comments)

### [emil-lp](<https://news.ycombinator.com/item?id=49882883>)

> CP here being Constraint Problem, or CSP (Constraint Satisfaction Problem).
>
> https://en.wikipedia.org/wiki/Constraint_satisfaction_proble...

### [sashank_1509](<https://news.ycombinator.com/item?id=49881398>)

> 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.

### [nh23423fefe](<https://news.ycombinator.com/item?id=49881046>)

> \> 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.

---

## Cite

- Page: https://zeli.app/story/49870760
- Date: 2026-09-27
- Source: thill.me (https://thill.me/2026/07/16/corn-puzzle-sat-solver.html)
- Hacker News: https://news.ycombinator.com/item?id=49870760

## Other languages

- zh: https://zeli.app/zh/story/49870760 · markdown: https://zeli.app/zh/story/49870760.md
- ja: https://zeli.app/ja/story/49870760 · markdown: https://zeli.app/ja/story/49870760.md
- ko: https://zeli.app/ko/story/49870760 · markdown: https://zeli.app/ko/story/49870760.md
- de: https://zeli.app/de/story/49870760 · markdown: https://zeli.app/de/story/49870760.md
- es: https://zeli.app/es/story/49870760 · markdown: https://zeli.app/es/story/49870760.md
- ru: https://zeli.app/ru/story/49870760 · markdown: https://zeli.app/ru/story/49870760.md
