Skip to content

Commit 01c288b

Browse files
Merge pull request #48 from SaridakisStamatisChristos/codex/add-test-for-swordfish_col-strategy
Add column swordfish regression test
2 parents 0eab059 + 78ee3e7 commit 01c288b

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

tests/test_strategies_extras.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,34 @@ def test_swordfish_synthetic_single_elimination() -> None:
2020
assert digit not in cand[move["r"]][move["c"]]
2121

2222

23+
def test_swordfish_col_eliminates_extra_row_candidate() -> None:
24+
grid = [[0] * 9 for _ in range(9)]
25+
cand = candidates(grid)
26+
digit = 7
27+
rows = [0, 4, 8]
28+
cols = [1, 4, 7]
29+
30+
for r in range(9):
31+
for c in range(9):
32+
cand[r][c].discard(digit)
33+
34+
for c in cols:
35+
for r in rows:
36+
cand[r][c].add(digit)
37+
38+
target_row = rows[0]
39+
target_col = 0
40+
cand[target_row][target_col].add(digit)
41+
42+
move = apply_swordfish(grid, cand)
43+
44+
assert move is not None
45+
assert move["strategy"] == "swordfish_col"
46+
assert move["digit"] == digit
47+
assert (move["r"], move["c"]) == (target_row, target_col)
48+
assert digit not in cand[target_row][target_col]
49+
50+
2351
def test_simple_coloring_one_elimination() -> None:
2452
grid = [[0] * 9 for _ in range(9)]
2553
cand = candidates(grid)

0 commit comments

Comments
 (0)