3 ms·
Your article is fantastic. I really like the way you present information, especially with the interactive examples. I've been playing a lot with the logic prog
by alexworks 2y ago
Your article is fantastic. I really like the way you present information, especially with the interactive examples.
I've been playing a lot with the logic programming language, Prolog. Sudoku is a popular "hello world" for it.
If you haven't used Prolog before, here's an example of a Sudoku solver. It uses Prolog's Constraint Logic Programming over Finite Domains library -- CLP(FD) -- a form of CSP.
https://swish.swi-prolog.org/example/clpfd_sudoku.pl https://swish.swi-prolog.org/example/clpfd_sudoku.pl
The relation on line 8 basically encodes the rules of Sudoku verbatim. Logic programming is cool (at least to me) because relations can be run in any direction with any number of variables.
I wonder how writing a Sudoku puzzle generator would differ in a language that had first-class support for CSP.