3 ms·
This is a specific example of an Exact cover problem: https://en.wikipedia.org/wiki/Exact_cover https://en.wikipedia.org/wiki/Exact_cover If you haven't seen
by periodontal 9y ago
This is a specific example of an Exact cover problem: https://en.wikipedia.org/wiki/Exact_cover https://en.wikipedia.org/wiki/Exact_cover
If you haven't seen Knuth's Dancing Links implementation of Algorithm X, I highly recommend it. It's based on the observation that updating a doubly-linked list in-place preserves enough information to make backtracking easy.
- denfromufa 9y agowow, this is insightful generalization
- jxramos 9y agoI feel like I may be missing something in comprehending that first up mathematical definition in the Exact cover wiki. How is it different from a partition of a set? (https://en.wikipedia.org/wiki/Partition_of_a_set https://en.wikipedia.org/wiki/Partition_of_a_set). UPDATE: think I may see it, sounds like in terms of partitions an exact cover is a subset of a set's partition.
- kybernetikos 9y agoMy JS implementation is http://dancing-links.herokuapp.com/ http://dancing-links.herokuapp.com/ It includes a sudoku (also exact cover) and pentonimo solver.
- carapace 9y agoThis make me want to dig up a version I did in Python (for Sudoku as it happens.) The algorithm is a bad fit for Python because attributes are not pointers, but have a look at this: http://www.cs.mcgill.ca/~aassaf9/python/algorithm_x.html http://www.cs.mcgill.ca/~aassaf9/python/algorithm_x.html > One day I decided to write Algorithm X in Python, and I came up with a very interesting variation on Dancing Links.
- kybernetikos 9y agoThat's really fun.