Skip to content
Back to Projects
DeployedGames/Puzzles

CSP Sudoku Solver

Constraint satisfaction solver using backtracking, AC-3 arc consistency, and MRV heuristic for efficient puzzle solving.

AIPythonCSP

The Problem

Brute-forcing a hard Sudoku is slow. With the right constraint propagation, most puzzles collapse to a solution with little or no backtracking.

Architecture & Approach

Constraint satisfaction with backtracking, AC-3 arc consistency preprocessing, and MRV heuristic for intelligent variable ordering.

Key Technical Decisions

AC-3 arc consistency before any search

Propagating constraints first strips impossible values from every cell up front. Many puzzles fall out from propagation alone, and the rest start from a much smaller search space.

MRV heuristic for variable ordering

When search is still needed, filling the cell with the fewest remaining candidates first fails fast on dead ends and keeps the branching factor low, instead of marching through the grid in row order.

Results

Solve any grid in the browser. The Solve button runs the CSP solver and fills a valid solution in well under a second.

Interactive Demo