gama843
Re:From hours to 360ms: over-engineering a puzzle solution
on Sunday February 09, 2025 @08:12AM (#42990461)
Hi, there is a better tool for the job! What you need is a constraint satisfaction solver and 27 All-Different constraints (9 for rows, 9 for cols and 9 for the 3x3 boxes). I just quickly put this together with Claude, because who's got time for writing a custom code for a HN comment. The best I got with Python and a CSP solver is 0.0038 seconds for a single puzzle. I include the code so you can try it yourself and see how it's done.
Daniel
pure python version (Time taken: 0.1341 seconds): https://gist.github.com/gama843/fc183791f77ca1e4d07bdf4afec2...
python with a CSP solver (Time taken: 0.0038 seconds): https://gist.github.com/gama843/b7f88bb2f18e22245cd13cffa82c...
If you want to understand how it works (it specifically mentions Sudoku), have a look at lecture slides (in English) from my uni: http://ktiml.mff.cuni.cz/~bartak/ui/lectures/lecture06eng.pd...
Re:Francois Chollet is leaving Google
on Thursday November 14, 2024 @05:47AM (#42134936)
Hi Francois,
any chance to work or at least intern (remote, unpaid) with you directly? Would be super interesting and enriching.