Sudoku
sudoku solver using CSP forward-tracking algorithms.
Description
Sudoku is a logic-based game that consists of 9 3x3 grids that create one large 9x9 grid. The rules of the game are simple: each row has all the numbers from 1-9, each column has all the numbers from 1-9, each individual 3x3 box has all the numbers from 1-9. The start state is the partially filled out board while the end state is all the tiles in the board filled according to the rules provided above.
Features
For each position, p
, of the 9 × 9 grid (ie. sudoku puzzle), determine the three constraint sets that it falls into. For each position, p
, of the 9 × 9 grid, determine (and put into a list or dictionary) all the other positions that are in a common constraint set with p
. These positions are the NEIGHBORS
of p
.
NEIGHBORS = {p:[ indices in same row, col, and subblock ]}
A simple checkSum(pzl) function: sum the ascii value of each symbol in your puzzle and subtract (the length of the puzzle) * (the ascii value of the min symbol in your puzzle). This is a simple way of double checking the Sudoku solution correctness.
Part 1: SudokuSingle
Solving a sudoku puzzle using the backtracking search algorithm.
Part 2: SudokuMass
Solving sudokus from a file. The algorithm implements forward-checking, making it faster.
Output format: display the puzzle number (starting from 1) and puzzle, and on a second line the solution and the checksum. After solving all puzzles in the input file, print time for the all solutions.