4 ms·
Its very nicely coded and credit to the author, but I think people might infer from your description something more than its actually doing, which is basically
by twelvechairs 14y ago
Its very nicely coded and credit to the author, but I think people might infer from your description something more than its actually doing, which is basically 'brute force' - trying every combination and crossing them off when they fail (hence your quoted code above).
The alternative approach would be to work like humans do, looking for the next 'right' square (rather than this, which looks for the next 'wrong' combination). This would be much more difficult but would solve the hard problems much faster and computationally elegantly (though its only a matter of seconds anyway!).
[EDIT] I created an derivative version in ruby for anyone who is interested (42 lines of code - probably could be shorter) - http://pastebin.com/ecjQzzU6 http://pastebin.com/ecjQzzU6
- riffraff 14y agoIs this really what is happening? I don't understand much clojure but looking at it it would seem to me the solution is actually found in a smart way, iteratively restricting the domains for a single variable and then propagating the changes (which I think is the standard constraint programming approach). In ruby you'd do something similar with gecoder.
- twelvechairs 14y agoSorry. Right you are. Obviously I completely misread it Humble pie for me. And wow now I understand what the fuss was. That is amazing