From 504814bd30a0de2d96ff57846fa97419bfd23859 Mon Sep 17 00:00:00 2001 From: Aleksei Maslakov Date: Fri, 27 Dec 2019 19:12:56 +0300 Subject: [PATCH 1/3] Mypy badge --- README.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.rst b/README.rst index fe307a5..6d90e0c 100644 --- a/README.rst +++ b/README.rst @@ -12,6 +12,10 @@ Overview :alt: Coverage Status :target: https://codecov.io/gh/unmade/dokusan +.. image:: http://www.mypy-lang.org/static/mypy_badge.svg + :alt: Checked with mypy + :target: http://mypy-lang.org/ + .. image:: https://img.shields.io/pypi/v/dokusan.svg :alt: PyPI Package latest release :target: https://pypi.org/project/dokusan From f8e0275919901c88566cf1beaae90d20c0054be3 Mon Sep 17 00:00:00 2001 From: Aleksei Maslakov Date: Fri, 27 Dec 2019 19:31:15 +0300 Subject: [PATCH 2/3] Search locked candidates in all groups --- src/dokusan/techniques.py | 2 +- tests/test_techniques.py | 31 ++++++++++++++++++++++++++++++- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/src/dokusan/techniques.py b/src/dokusan/techniques.py index 4977c6c..2a645ef 100644 --- a/src/dokusan/techniques.py +++ b/src/dokusan/techniques.py @@ -183,7 +183,7 @@ def _get_changes(self, combination: Combination) -> List[Cell]: class LockedCandidate(Technique): def _find(self) -> Iterator[Combination]: - for group in self.sudoku.boxes(): + for group in self.sudoku.groups(): candidate_map: Dict[int, List[Cell]] = {} for cell in group: if cell.candidates: diff --git a/tests/test_techniques.py b/tests/test_techniques.py index ecde06f..105e314 100644 --- a/tests/test_techniques.py +++ b/tests/test_techniques.py @@ -315,7 +315,7 @@ def test_naked_triplet_not_found(): techniques.NakedTriplet(sudoku).first() -def test_locked_candidate(): +def test_locked_candidate_in_a_box(): sudoku = make_sudoku_with_marks( [ [2, 0, 0, 5, 9, 3, 1, 0, 0], @@ -354,6 +354,35 @@ def test_locked_candidate(): ] +def test_locked_candidate_in_a_row(): + sudoku = make_sudoku_with_marks( + [ + [9, 0, 0, 5, 3, 1, 2, 8, 0], + [0, 2, 5, 7, 0, 4, 9, 3, 0], + [0, 3, 0, 0, 0, 2, 0, 4, 0], + [4, 8, 1, 2, 5, 7, 6, 9, 3], + [3, 5, 9, 0, 0, 8, 0, 0, 2], + [7, 6, 2, 3, 1, 9, 8, 5, 4], + [0, 1, 0, 0, 0, 0, 0, 6, 8], + [6, 0, 8, 1, 0, 5, 3, 0, 0], + [0, 0, 3, 8, 7, 6, 0, 0, 0], + ], + box_size=BoxSize(3, 3), + ) + + locked_candidate = techniques.LockedCandidate(sudoku).first() + + assert locked_candidate.combination.cells == [ + Cell(position=Position(6, 3, 7), candidates={4, 9}), + Cell(position=Position(6, 4, 7), candidates={2, 4, 9}), + ] + assert locked_candidate.combination.values == [9] + + assert locked_candidate.changes == [ + Cell(position=Position(7, 4, 7), candidates={2, 4}) + ] + + def test_locked_candidate_not_found(): sudoku = make_sudoku_with_marks( [ From dc0caada49052ed11ff22d2ae622e4cffe451905 Mon Sep 17 00:00:00 2001 From: Aleksei Maslakov Date: Fri, 27 Dec 2019 19:31:55 +0300 Subject: [PATCH 3/3] Bump version --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 260ccc7..5f58428 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "dokusan" -version = "0.1.0-alpha.4" +version = "0.1.0-alpha.5" description = "Sudoku generator and solver with a step-by-step guidance" keywords = ["sudoku", "sudoku-solver", "sudoku-generator", "solver", "generator"] readme = "README.rst"