3 ms·
I don't think it's too much code. Sudoku solving is nontrivial, and this is a complete application consisting of all of the IO handling, pretty printing, tests,
by vito 17y ago
I don't think it's too much code. Sudoku solving is nontrivial, and this is a complete application consisting of all of the IO handling, pretty printing, tests, guessing, etc. The actual solving is roughly 2/3rds of this source.
Haskell is consise in the sense that you can accomplish a lot with small definitions - as you'll note, many of those functions are one-liners and exist solely to give meaning/value to something that is otherwise unclear. Even if the definition is used only once (or never used at all), it's well worth doing just for clarity and reusability's sake.
That being said, there are a few warts in there - basically anything to do with the "boxes" I had to do a lot of repetitive ugly lines. I could probably have changed the structure of the grid to denote boxes, but this was a learning experience.
(edit: re: the logic and everything, it's all explained at the bottom of the readme though I'd be happy to expound upon it)