It causes me unspeakable agony to see that my post about why sudoku is boring is one of the most frequented posts in this blog, mostly because most of my readers clearly disagree with the title. I recently received an email titled "why sudoku is not all that boring" by an old friend, and he taunted me that the sudoku
S = [
0, 0, 0, 0, 6, 0, 0, 8, 0,
0, 2, 0, 0, 0, 0, 0, 0, 0,
0, 0, 1, 0, 0, 0, 0, 0, 0,
0, 7, 0, 0, 0, 0, 1, 0, 2,
5, 0, 0, 0, 3, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 4, 0, 0,
0, 0, 4, 2, 0, 1, 0, 0, 0,
3, 0, 0, 7, 0, 0, 6, 0, 0,
0, 0, 0, 0, 0, 0, 0, 5, 0 ]
would take my 5-minute hack of a backtracking algorithm
real 51m3.656s
user 50m32.260s
sys 0m2.084s
to solve. So, it seems like some sudokus are really hard, even for a computer, right? Wrong wrong wrong wrong wrong. Read how to implement backtracking properly.