3 ms·
Back in college I took a class in Prolog. We had to implement a Sudoku solver and at some point I got stuck. I was trying to bring over my imperative programmi
by synthc 3y ago
Back in college I took a class in Prolog.
We had to implement a Sudoku solver and at some point I got stuck.
I was trying to bring over my imperative programming mindset, I had written a solver in Java before and I tried to port over the Java code to Prolog, which did not work at all.
So at some point I started over, and wrote some simple Prolog code to check if the Sudoku is valid.
Then I realized that I could also run these predicates to solve the Sudoku, and I completed the solver in under 10 lines.
It was a real eureka moment, Prolog is very powerful, but criminally underused in practice, fortunately I had the opportunity to work with Datalog and OWL.