Please help a newbie porting Norvig's Sudoku solver

I have started porting this to Elixir to learn the basics. After a few false starts I got far with code that at least to my eyes doesn’t look particularly horrible.

It might be argued my Enum.reduce() loops are a bit cheating… and actually, are they? Is this very bad practice?

The bigger problem is I can’t really get the actual search working. Any pointers (or captures because this language doesn’t have pointers :wink: )?

Finally the display is not finished but that’s not a big challenge. I am still very confused by when and how does Elixir decide to print the integers represented by a charlist (like, how do you convert a charlist to a string and not get 4950 instead of AB etc) and when it decides to use the characters but I guess practice will help.


Enum.reduce is one of the 2 basic operations, the other being flat_map, always feel free to use it. ^.^

Can always carry an environment and pretend pointers are keys on a map and the values are what the pointers point to, just thread the environment in and out of all calls. :slight_smile:

“If every element in a charlist is an integer and each integer is inside the Printable Range then display it like a String by default”, you can of course override the default to print it however you want too, see the options on the calls. :slight_smile:

Or just put 0 on the list somewhere, it is not printable so will always cause the list to not be printable too. ^.^

I have ported search() but it doesn’t quite work and I do not see where I am wrong (I surely am). If someone could look into it that’d be great. Thanks for your time!