Another way to solve Sudoku is to understand that it is an instance of the Exact Cover problem [1]. Basically, solving a 3x3 Sudoku grid is nothing more than finding 9 "sheets" of each number which superimpose exactly on top of the
grid.<p>For example (2x2 sudoku = 4 sheets):<p><pre><code> 1324
3142
4213
2431
</code></pre>
is:<p><pre><code> 1... .2.. .3.. ...4
.1.. ...2 3... ..4.
..1. + .2.. + ...3 + 4...
...1 2... ..3. .4..
</code></pre>
or even:<p><pre><code> x... .x.. .x.. ...x
.x.. ...x x... ..x.
..x. + .x.. + ...x + x...
...x x... ..x. .x..
x... .x.. ..x. ...x <- number row
</code></pre>
where the last "number row" does not belong to the grid but serves to indicate the number of the sheet.<p>This explains how sudoku relates to the Exact Cover problem. Now, there is a good algorithm by Knuth to solve Exact Cover, which is known as Algorithm X [2].<p>Algorithm X is just an algorithm but Knuth has also invented a very efficient implementation of it, called Dancing Links or DLX for short [3]. DLX is described in a very good and very readable paper by Knuth himself [4]. This is one of the first serious papers I ever read and it was a real joy, mind-opener.<p>[1] <a href="https://en.wikipedia.org/wiki/Exact_cover" rel="nofollow">https://en.wikipedia.org/wiki/Exact_cover</a><p>[2] <a href="https://en.wikipedia.org/wiki/Knuth%27s_Algorithm_X" rel="nofollow">https://en.wikipedia.org/wiki/Knuth%27s_Algorithm_X</a><p>[3] <a href="https://en.wikipedia.org/wiki/Dancing_Links" rel="nofollow">https://en.wikipedia.org/wiki/Dancing_Links</a><p>[4] <a href="http://www-cs-faculty.stanford.edu/~uno/papers/dancing-color.ps.gz" rel="nofollow">http://www-cs-faculty.stanford.edu/~uno/papers/dancing-color...</a>