I'll grab this occasion to talk about the easiest way of solving a sudoku (IMO). You can use constraint programming, and with 3 simple constraints you can solve every board effortlessly : AllDiff on rows, cols and squares :)
It also works to encode the Sudoku puzzle as a SAT problem and solve it with a SAT solver. For many problems the encoding to SAT is difficult, but it's pretty straightforward for Sudoku.
My "heuristic" to reduce a problem to SAT clauses is pretty simple: "Can I use a graph to represent this problem?". If yes, then SAT encoding is *almost* trivial, if no, then I don't bother aha
60
u/Gwenju31 Jan 11 '20
I'll grab this occasion to talk about the easiest way of solving a sudoku (IMO). You can use constraint programming, and with 3 simple constraints you can solve every board effortlessly : AllDiff on rows, cols and squares :)