Saturday, June 03, 2006
OCaml and Sudoku
I was pretty proud of my program, which solved sudokus in a fraction of a second. Then I ran across a 19-line OCaml sudoku solver on the Internet. Mine is 187 lines (including comments and blank lines).
I don't understand the 19-line version. It makes me feel stupid.
I take some solace from the facts that I'm a beginner, that I wrote my code for clarity rather than conciseness, and that I wrote a functional-style program, whereas the 19-line version uses some imperative features. But still, I am very concerned that I just do not understand the 19-line version, and it doesn't look that tricky.
Maybe I need to stick with C++. I guess I've become an old dog.
[UPDATE: After getting some sleep, the 19-line code made sense to me. I had to have a fresh brain to make sense of all those tightly-packed m's, n's, x's, y's and i's.]