Solving Sudoku using Brute Force

Solving Sudoku puzzles using a computer program is both easy and hard. Some easy puzzles can be solved using brute force. By that I mean, the computer program visits each empty cell/square and checks every possible 1-9 number. If only one number is legal in the square, then the number is placed in the empty square.

Most Sudoku puzzles that are published in newspapers and magazines can be solved this way. Hard Sudoku puzzles require a more sophisticated approach.

I wrote a brute force Sudoku solver, mostly for my own entertainment. In the example below, the program starts by checking the empty cell in the upper left hand corner. The only possible value that can be placed there is a 6, so a 6 is placed there and the program moves to the next cell.

Anyway, writing a brute force Sudoku puzzle solver program was good mental exercise.


This entry was posted in Machine Learning, Miscellaneous. Bookmark the permalink.