Kakuro solver

A C++ constraint satisfaction solver for kakuro puzzles, started during a long flight to Japan. Born from an unfinished high school sudoku solver and the itch to tackle a similar problem from scratch.

Backstory

Back in high school, I made a sudoku solver. It was decent and managed to complete most problems I threw its way, but it struggled with the more difficult ones — and I never got around to implementing the advanced strategies (X-wing, Y-wing, swordfish… it felt more like building a Star Wars simulation than a puzzle solver). I moved on to other projects, and the repo stayed as a time capsule of code from my younger days.

Over the years I kept thinking about going back, but rewriting old code didn’t appeal to me. Then I got the idea: a new solver, not for sudoku, but for kakuro — a similar constraint satisfaction problem, without retreading old ground. And because it had been a while since I last wrote C++, it became the project I started coding during a long flight to Japan.

Approach

I wanted to go in “blind” — figuring out solving strategies on my own before looking up the optimal approaches on Wikipedia. Part of the fun in hobby projects is seeing how far you can get before reaching for external resources, especially when you have an idea of how to tackle it.

Since I had recently been doing a lot of functional programming in TypeScript, I had to resist the instinct and write more object-oriented, with a focus on classes and their owned functions.

How it works

Kakuro is a constraint satisfaction problem — each cell must satisfy both a row and column sum constraint using unique digits 1-9. The solver uses restriction-based propagation: narrowing possible values for each cell based on its constraints, then backtracking when needed.

Architecture

  • Tile — represents a single cell (value, clue, or empty)
  • Board — the grid, handles parsing and neighbor lookups
  • Kakuro — orchestrates the puzzle state and validation
  • Solver — constraint propagation + backtracking

Built with a TUI for interactive puzzle loading and visualization.