-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* finish up adding topo * refactor the cli * formatting
- Loading branch information
Showing
8 changed files
with
205 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
def is_circular_reversible_permutation(lst: list, candidate: list) -> bool: | ||
"""the output cycle is non-deterministic, it could be reversed and any node could be the start""" | ||
extended_lst = lst + lst | ||
extended_lst_reverse = lst[::-1] + lst[::-1] | ||
return any(extended_lst[i : i + len(candidate)] == candidate for i in range(len(lst))) or any( | ||
extended_lst_reverse[i : i + len(candidate)] == candidate for i in range(len(lst)) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import itertools | ||
|
||
import pytest | ||
|
||
from cycl.utils.testing import is_circular_reversible_permutation | ||
|
||
# neat that every permutation of 1, 2, 3 is True | ||
permutations = list(itertools.permutations([1, 2, 3])) | ||
|
||
|
||
@pytest.mark.parametrize( | ||
('lst', 'candidate', 'expected'), | ||
[ | ||
*[([1, 2, 3], list(candidate), True) for candidate in permutations], | ||
([1, 2, 3, 4], [3, 4, 2, 1], False), | ||
], | ||
) | ||
def test_is_circular_reversible_permutation(lst, candidate, expected): | ||
actual = is_circular_reversible_permutation(lst, candidate) | ||
assert actual == expected |