Skip to content

Commit

Permalink
improvement: waking up with OCD and coffee
Browse files Browse the repository at this point in the history
  • Loading branch information
mlbright committed Dec 8, 2023
1 parent 5fa9816 commit 0836f6e
Showing 1 changed file with 38 additions and 10 deletions.
48 changes: 38 additions & 10 deletions sudoku.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,21 +64,46 @@ def test():
assert len(unitlist) == 27
assert all(len(units[s]) == 3 for s in range(len(squares)))
assert all(len(peers[s]) == 20 for s in range(len(squares)))
assert units[19] == [
[1, 10, 19, 28, 37, 46, 55, 64, 73],
[18, 19, 20, 21, 22, 23, 24, 25, 26],
[0, 1, 2, 9, 10, 11, 18, 19, 20],
]
# assert units["C2"] == [
# ["A2", "B2", "C2", "D2", "E2", "F2", "G2", "H2", "I2"],
# ["C1", "C2", "C3", "C4", "C5", "C6", "C7", "C8", "C9"],
# ["A1", "A2", "A3", "B1", "B2", "B3", "C1", "C2", "C3"],
# ]
assert peers[19] == {
0,
1,
2,
9,
10,
11,
18,
20,
21,
22,
23,
24,
25,
26,
28,
37,
46,
55,
64,
73,
}
# assert peers["C2"] == set(
# [
# "A1",
# "A2",
# "A3",
# "B1",
# "B2",
# "D2",
# "E2",
# "F2",
# "G2",
# "H2",
# "I2",
# "B3",
# "C1",
# "C3",
# "C4",
Expand All @@ -87,10 +112,12 @@ def test():
# "C7",
# "C8",
# "C9",
# "A1",
# "A3",
# "B1",
# "B3",
# "D2",
# "E2",
# "F2",
# "G2",
# "H2",
# "I2",
# ]
# )
print("All tests pass.")
Expand Down Expand Up @@ -280,6 +307,7 @@ def random_puzzle(N=17):
".....6....59.....82....8....45........3........6..3.54...325..6.................."
)


if __name__ == "__main__":
test()
solve_all([random_puzzle() for _ in range(99)], "random", 100.0)
Expand Down

0 comments on commit 0836f6e

Please sign in to comment.