2 ms·
It really depends on why you want to solve them. In some cases you might want the algorithm that solves them to also give you some kinda hint on how hard it wo
by bobfunk 16y ago
It really depends on why you want to solve them.
In some cases you might want the algorithm that solves them to also give you some kinda hint on how hard it would be for a human to solve it.
The most efficient algorithm I know of to solve these kind of problems is Knuth's Dancing Links X algorithm. It's beautiful and very fun to implement.
I have a simple ruby implementation of it geared to solve sudokus online on github: https://github.com/biilmann/Ruby-DLX-Sudoku-Solver https://github.com/biilmann/Ruby-DLX-Sudoku-Solver