Sodoku SQL Solution
In case this blog hasn’t been meeting its geekiness quota, I present the following. Ken (who deserves to be better known in the blogosphere and elsewhere) wrote a Haskell program to solve Sodoku with a single SQL query:
SELECT * FROM values AS aaaa, values AS aaab, values AS aaba, values AS aabb, values AS aabc, values AS aaca, values AS abab, values AS abba, values AS abbb, values AS abbc, values AS abcb, values AS abcc, values AS acba, values AS acbc, values AS acca, values AS accc, values AS baaa, values AS baac, values AS babb, values AS babc, values AS bacb, values AS bacc, values AS bbba, values AS bbbc, values AS bcaa, values AS bcab, values AS bcba, values AS bcbb, values AS bcca, values AS bccc, values AS caaa, values AS caac, values AS caba, values AS cabc, values AS cbaa, values AS cbab, values AS cbba, values AS cbbb, values AS cbbc, values AS cbcb, values AS ccac, values AS ccba, values AS ccbb, values AS ccbc, values AS cccb, values AS cccc WHERE aaaa.v <> 3 AND aaaa.v <> 9 AND aaaa.v <> baaa.v AND aaaa.v <> 4 AND aaaa.v <> bcaa.v AND aaaa.v <> caaa.v AND aaaa.v <> cbaa.v AND aaaa.v <> 8 AND 3 <> 9 AND 3 <> baaa.v AND 3 <> 4 AND 3 <> bcaa.v AND 3 …
(edited for brevity)
Steve Laniel Jun 11
In case it’s not clear, I’m pretty sure the SQL query will depend on the particular filled-in squares on the board.
Steve Laniel Jun 11
Also: s/sodoku/sudoku/gi .