21

Learning from Sudoku Solvers (2007)

Or perhaps just use a language that's designed to solve those sorts of problems? In 14 lines of code.

https://www.swi-prolog.org/pldoc/man?section=clpfd-sudoku

6 hours agocrustycoder

Is there a similarly short/simple solution not using all of the built ins? Haven't worked with prolog in a while but should be easy enough with primitives (albeit with more duplication)?

4 hours agocenamus

Why not just

    blocks(Rows, Blocks), maplist(all_distinct, Blocks), maplist(label, Rows)
4 hours agonurettin

I remember implementing some of these

https://www.stolaf.edu/people/hansonr/sudoku/12rules.htm

With a simple array of unsigned int and bit operations like 20 years ago. It could solve a lot of puzzles within microseconds. Later I realized rules 1, 2, 5, 6 are pretty much the same.