iSudoku
Computing Solutions to Sudoku Puzzles w/ 3 Algorithms
by:
Gavin Hillebrand Jamie Sparrow Jonathon Makepeace Matthew Harris
iSudoku Computing Solutions to Sudoku Puzzles w/ 3 Algorithms by: - - PowerPoint PPT Presentation
iSudoku Computing Solutions to Sudoku Puzzles w/ 3 Algorithms by: Gavin Hillebrand Jamie Sparrow Jonathon Makepeace Matthew Harris What is Sudoku? Region 1 Column 6 A logic-based puzzle game Heavily based in combinatorics
Computing Solutions to Sudoku Puzzles w/ 3 Algorithms
by:
Gavin Hillebrand Jamie Sparrow Jonathon Makepeace Matthew Harris
regions) such that no row, column, nor region of cells contains the digit more than once
numbers to work with
Region 1 Row 6 Column 6
Given: Solution:
A formal definition of the problem of solving a Sudoku puzzle: Given an n × n Sudoku grid, the Sudoku is successfully solved if:
numberAt(i, j) = x. (“For any given number x [between 1 and n] and row number i [between 1 and n], there is
a column number j [between 1 and n] such that x can be found in row i, column j.”)
numberAt(i, j) = x. (“For any given number x and column number j, there is a row number i...)
≤ n) such that regionOf(i,j) = r AND numberAt(i,j) = x.
Iterate over the cells in the puzzle, and for each cell: 1. Place a number (in the case of a 9 × 9 grid) between 1 and 9 in that empty cell. 2. Check that the placed number does not violate any of the three constraints (duplicate number in its row, column, or region). 3. If any constraint is violated, backtrack and place the next greater number in the cell. 4. Repeat until all cells have been filled.
varying difficulty
a total of 30 puzzles)
avg/min/max runtime across all solutions.
Total time taken 248.48 ms Average time per puzzle 2.48 ms Fastest solve (minimum time) 0.63 ms Slowest solve (maximum time) 14.31 ms
1. Setup initial matrix with constraints, column headers, and node pointers directed to neighbors and their column headers 2. For a row satisfying a constraint, remove the column and the rows intersecting that column (ie covering a node/column) 3. If no solution is found, backtrack in the exact reverse order nodes were covered (ie uncover a node/column) 4. Continue covering until the solution to the constraints is found
Total time taken 19.62 ms Average time per puzzle 0.1962 ms Fastest solve (minimum time) 0.1834 Slowest solve (maximum time) 0.7952
paper.
possibilities, then crosses out as it test each value.
possible sets together for a solution.
1. Mark up the cells ie. list of numbers that the cell may contain. 2. Look at each column, row and 3x3 box and break down into preemptive sets. Break down the sets and use Occupancy Theorm whenever possible. 3. Determine if puzzle is: Finished, not possible or next step. 4. Choose an empty cell and mark a number and color. Repeat step 2 until no more preemptive sets remain. 5. Go through the markup until you solve or determine as not possible.
Total time taken 231.64 ms Average time per puzzle 2.31 ms Fastest solve (minimum time) 0.74 ms Slowest solve (maximum time) 12.42 ms
efficient based on time constraints. This result matches with our initial estimate at the beginning of the project.
1. Based on Crook’s Algorithm, what is the difference between a preemptive set and a markup? A: Markup is the list of possible values for each cell. Preemptive set are numbers that are potential occupants
A: Backtracking will check if the number can legally be placed in the cell.
A: The amount of conceptual moves needed to complete the puzzle
A: Depth-first
A: The increase in blank spaces is one reason, because it has more cells to create the markup and preemptive sets on each one.
A genetic algorithm is a metaheuristic algorithm inspired by the process of natural selection that belongs to the larger class of evolutionary algorithms.
population and start over at 1.