Wolfram Library Archive

All Collections Articles Books Conference Proceedings
Courseware Demos MathSource Technical Notes
Title Downloads

Solving Sudoku Using Combinatorica`Backtrack

Frank Kampas
Organization: Physicist at Large Consulting
Revision date


A Sudoku can be regarded as a Constraint Satisfaction Problem with 27 All-Different constraints. Two methods of solving Sudoku are described. Both start by generating the possibilities for each row which satisfy the constraints, consistent with the given values. The first method then uses the "Backtrack" function in the Combinatorica package to build the solution row by row using the constraints. The second method also builds the solution row by row, using "Outer" to find all possibilities for the partial solution and selecting out those which satisfy the constraints. One notebook (Solving ...) explains the two methods in detail. The other notebook compares the two for several test cases.

*Applied Mathematics > Computer Science
*Mathematics > Discrete Mathematics > Combinatorics
*Wolfram Technology > Programming > Equation Solving

Sudoku, Combinatorica, Backtrack, Constraint Satisfaction Programming
Downloads Download Wolfram CDF Player

SolvingSudokuUsingCombinatoricaBacktrack.nb (62.8 KB) - Mathematica Notebook [for Mathematica 7.0]
SudokuSolverFunctions.nb (37.9 KB) - Mathematica Notebook [for Mathematica 7.0]