Sudoku solver using recursive backtracking

Inspired by a video lecture from Stanford University about recursive backtracking and how it can be useful, I sat up all night to write my own recursive backtracker to solve Sudoku’s. You can see it here. The video lecture presents a pseudocode in C++, and there is little to no emphasis on the code itself. While writing the code in Java, I ended up having to make a lot of design decisions, and when it eventually ‘clicked’, I had an ‘aha’ moment. So you can try to download the code, follow the instructions, make it solve a Sudoku of any level of difficulty, and try to break it. Just a little caveat – if you give it an evil or diabolical Sudoku, you will have to increase the stack size of your JVM [up to 50m].

Have fun!

Advertisements