Add Dancing Links (DLX) algorithm for Exact Cover problem - #13183
Conversation
|
Please, Merge this request i was doing the fixes from last 2 days, it would be appreciated |
Added references to Wikipedia for Algorithm X and Dancing Links.
There was a problem hiding this comment.
Click here to look at the relevant links ⬇️
🔗 Relevant Links
Repository:
Python:
Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.
algorithms-keeper commands and options
algorithms-keeper actions can be triggered by commenting on this PR:
@algorithms-keeper reviewto trigger the checks for only added pull request files@algorithms-keeper review-allto trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.
| class DLXNode: | ||
| """Represents a node in the Dancing Links structure.""" | ||
|
|
||
| def __init__(self): |
There was a problem hiding this comment.
Please provide return type hint for the function: __init__. If the function does not return a value, please provide the type hint as: def function() -> None:
| class ColumnNode(DLXNode): | ||
| """Represents a column header node, keeping track of its column size.""" | ||
|
|
||
| def __init__(self, name): |
There was a problem hiding this comment.
Please provide return type hint for the function: __init__. If the function does not return a value, please provide the type hint as: def function() -> None:
Please provide type hint for the parameter: name
| class DancingLinks: | ||
| """Dancing Links structure for solving the Exact Cover problem.""" | ||
|
|
||
| def __init__(self, universe, subsets): |
There was a problem hiding this comment.
Please provide return type hint for the function: __init__. If the function does not return a value, please provide the type hint as: def function() -> None:
Please provide type hint for the parameter: universe
Please provide type hint for the parameter: subsets
| first_node.left.right = node | ||
| first_node.left = node | ||
|
|
||
| def _cover(self, col): |
There was a problem hiding this comment.
Please provide return type hint for the function: _cover. If the function does not return a value, please provide the type hint as: def function() -> None:
Please provide type hint for the parameter: col
| node = node.right | ||
| row = row.down | ||
|
|
||
| def _uncover(self, col): |
There was a problem hiding this comment.
Please provide return type hint for the function: _uncover. If the function does not return a value, please provide the type hint as: def function() -> None:
Please provide type hint for the parameter: col
| col.right.left = col | ||
| col.left.right = col | ||
|
|
||
| def _choose_column(self): |
There was a problem hiding this comment.
Please provide return type hint for the function: _choose_column. If the function does not return a value, please provide the type hint as: def function() -> None:
| col = col.right | ||
| return chosen | ||
|
|
||
| def _search(self): |
There was a problem hiding this comment.
Please provide return type hint for the function: _search. If the function does not return a value, please provide the type hint as: def function() -> None:
|
|
||
| self._uncover(col) | ||
|
|
||
| def solve(self): |
There was a problem hiding this comment.
Please provide return type hint for the function: solve. If the function does not return a value, please provide the type hint as: def function() -> None:
There was a problem hiding this comment.
Click here to look at the relevant links ⬇️
🔗 Relevant Links
Repository:
Python:
Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.
algorithms-keeper commands and options
algorithms-keeper actions can be triggered by commenting on this PR:
@algorithms-keeper reviewto trigger the checks for only added pull request files@algorithms-keeper review-allto trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.
| node = node.right | ||
| row = row.down | ||
|
|
||
| def _uncover(self, col: ColumnNode): |
There was a problem hiding this comment.
Please provide return type hint for the function: _uncover. If the function does not return a value, please provide the type hint as: def function() -> None:
Describe your change:
This pull request adds the Dancing Links (DLX) algorithm for solving the Exact Cover problem, following Donald Knuth's Algorithm X. The implementation is placed in
other/dancing_links.py, includes type hints, docstrings, and a usage example. No such algorithm currently exists in this repository.Checklist: