🧩 Constraint Solving POTD:Problem of the Day: Sudoku Constraint Satisfaction #54505
Closed
Replies: 1 comment
|
This discussion has been marked as outdated by Constraint Solving — Problem of the Day. A newer discussion is available at Discussion #54778. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Problem Statement
Sudoku is a combinatorial puzzle where you fill a 9×9 grid divided into nine 3×3 blocks with digits 1–9 such that:
A valid puzzle provides a partial assignment and has a unique solution.
Small instance (4×4 variant):
Input: Partially filled grid (givens).
Output: Completed grid satisfying all constraints, or "no solution."
Why It Matters
Modeling Approaches
Approach 1: Constraint Programming (CP) — Explicit All-Different
Trade-offs:
Approach 2: SAT Encoding — Cardinality Constraints
Trade-offs:
Key Techniques
1. Arc Consistency (AC-3/AC-2001)
Sudoku's row/column/block constraints are pairwise incompatible. AC enforces that every value in a cell's domain has a compatible value in neighboring cells. Iterative application often solves puzzles with many givens without search.
2. Hidden Singles & Naked Singles
These are special cases of constraint propagation and solve ~90% of everyday puzzles.
3. Search with Minimum Remaining Values (MRV) + Backtracking
When propagation stalls, branch on the cell with smallest domain (most constrained variable heuristic). Use nogood recording or conflict-driven learning to prune redundant search space. For hard puzzles, restart heuristics improve performance.
Challenge Corner
Question for readers:
Sudoku has 6.67 × 1021 valid grids but only ~5.5 × 1015 essentially different solutions (accounting for symmetry).
Try modeling a 4×4 Sudoku variant in your favorite solver and experiment with these questions.
References
Rossi, F., van Beek, P., & Walsh, T. (Eds.) Handbook of Constraint Programming. Elsevier, 2006.
→ Comprehensive treatment of CSP theory and Sudoku as a case study.
Felgenhauer, B., & Jarvis, F. "Enumerating possible Sudoku grids." 2005.
→ Definitive source on the count of valid Sudoku grids and symmetry analysis.
Lynce, I., & Ouaknine, J. "Sudoku as a SAT Problem." AAAI Workshop on Advances in Verification, 2006.
→ Demonstrates SAT encoding and solver comparison.
Russell, S., & Norvig, P. Artificial Intelligence: A Modern Approach (4th ed.), 2020. Ch. 6.
→ Accessible introduction to CSP with Sudoku examples and live solver demo.
Next problem: Stay tuned for scheduling, routing, packing, and more! 🎯
All reactions