Re:Arthur Whitney's one liner sudoku solver
by Isamu on Saturday October 05, 2024 @09:55PM
(#41754163)
Not knowing K, am I correct in assuming this is a backtracking brute force solver?
[ Parent
| on HN ]
Re:Arthur Whitney's one liner sudoku solver
by o11c on Saturday October 05, 2024 @10:22PM
(#41754265)
From the linked page (and the one linked beyond that), it's a breadth-first search actually. Keep a list of possible puzzle states at all times, pick a blank cell (theoretically arbitrary, but in practice intelligently for performance), add copies of the state with each possibility for that state added.
Re:Arthur Whitney's one liner sudoku solver
by BobbyTables2 on Saturday October 05, 2024 @11:26PM
(#41754506)
That sounds like 100+ lines in python or similar languages…
Re:Arthur Whitney's one liner sudoku solver
by otteromkram on Saturday October 05, 2024 @11:51PM
(#41754616)
It probably isn't. At least, not for Python.
Re:Arthur Whitney's one liner sudoku solver
by throwup238 on Sunday October 06, 2024 @01:04AM
(#41754884)
You should be able to do it in under 20 lines using the same matrix operations as the K code via numpy.
Re:Arthur Whitney's one liner sudoku solver
by anonzzzies on Sunday October 06, 2024 @03:16AM
(#41755386)
Numpy is indeed very apl. Just more horrible to me; not python-y and annoyingly verbose for the apl-er.
A few years back I made a modest attempt at writing a concise yet readable sudoku solver in Python - in about 29 lines: https://github.com/hrzn/sudoku/blob/master/sudoku.py
Could have been made shorter at the price of readability.
Re:Arthur Whitney's one liner sudoku solver
by forgotpwd16 on Sunday October 06, 2024 @08:24AM
(#41756655)
Looks nice. Since imports numpy can utilize (more of) numpy's operations to squeeze validation functions and nested fors to one. Should result in shorter code but readability will probably depend on reader's experience in array programming.