Jan 23 2009

Learning Java: Brute Force Sudoku Solver

The next in my series of teach-myself-java programs is a brute force Sudoku solver. You give it a file (or a list of files) containing 9×9 sudoku grids (empty cells are represented with “-” or “0″), and it gives you the solution:

C:\Home\working\java\Sudoku>type problem1.txt
----6---9
-6----3-1
2----98--
196--2--8
---3-8---
8--9--175
--17----4
6-7----8-
4---9----

C:\Home\working\java\Sudoku>java -jar BruteForceSolver.jar problem1.txt
318267549
769854321
245139867
196572438
574318296
832946175
921783654
657421983
483695712

Downloads:
bruteforcesolver.zip – source files.
bruteforcesolver.jar – java archive.