Skip to content

Commit

Permalink
refactor sudoku solve
Browse files Browse the repository at this point in the history
  • Loading branch information
darius committed Jul 16, 2017
1 parent 1273270 commit 7934a4e
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions sat/sudoku.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
import indexedsat as solver
from sat import flatten, exactly_one, at_most_one

## unconstrained_sudoku(2)
## solve(make_sudoku_grid(2))
#. 4 3 | 2 1
#. 2 1 | 4 3
#. ---------
#. 3 4 | 1 2
#. 1 2 | 3 4
## unconstrained_sudoku(3)
## solve(make_sudoku_grid(3))
#. 9 8 7 | 6 5 4 | 3 2 1
#. 6 5 4 | 3 2 1 | 9 8 7
#. 3 2 1 | 9 8 7 | 6 5 4
Expand All @@ -34,7 +34,7 @@
hardestsudokuinworld = \
'85...24..72......9..4.........1.7..23.5...9...4...........8..7..17..........36.4.'

## solve(easy1)
## solve(read_sudoku_problem(easy1))
#. 4 8 3 | 9 2 1 | 6 5 7
#. 9 6 7 | 3 4 5 | 8 2 1
#. 2 5 1 | 8 7 6 | 4 9 3
Expand All @@ -47,13 +47,7 @@
#. 8 1 4 | 2 5 3 | 7 6 9
#. 6 9 5 | 4 1 7 | 3 8 2

def unconstrained_sudoku(n):
rows, problem = make_sudoku_grid(n)
model = solver.solve(problem)
print_sudoku_solution(rows, model)

def solve(form):
rows, problem = read_sudoku_problem(form)
def solve((rows, problem)):
model = solver.solve(problem)
print_sudoku_solution(rows, model)

Expand Down

0 comments on commit 7934a4e

Please sign in to comment.