Skip to content

Commit

Permalink
Fix (#39)
Browse files Browse the repository at this point in the history
* adding second csp solver

* coverage fix
  • Loading branch information
iheitlager authored Nov 21, 2023
1 parent 868f407 commit c85e1b0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
15 changes: 10 additions & 5 deletions simple_sudoku.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,16 @@ def solve_sudoku(grid):
[0, 0, 0, 0, 0, 0, 4, 0, 0]
]

if __name__ == '__main__':
print("Fill before rate: {0:d}".format(count_nonzero(sudoku_grid)))
solve_sudoku(sudoku_grid)
fr = count_nonzero(sudoku_grid)
def main(grid):
print("Fill before rate: {0:d}".format(count_nonzero(grid)))
res = solve_sudoku(grid)
fr = count_nonzero(grid)
frp = fr / 81 * 100.0
print("Fill after rate: {0:d} ({1:0.0f}%)".format(fr, frp))
print("Iterations: {0:d}".format(iterations))
display_grid(sudoku_grid)
display_grid(grid)
return res


if __name__ == '__main__':
main(sudoku_grid)
5 changes: 5 additions & 0 deletions test_simple_sudoku.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,8 @@ def test_solve():
assert ss.is_complete(g)
assert ss.count_nonzero(g) == 81
assert ss.find_empty_cell(g) == (None, None)


def test_main():
g = copy.deepcopy(ss.sudoku_grid)
assert ss.main(g)

0 comments on commit c85e1b0

Please sign in to comment.