From 8ba885f061d3c46c964e5f1715abd8f6c131f7c7 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Tue, 12 Oct 2010 08:29:42 -0400 Subject: [PATCH] Fix "failed to solve" comparison in sudoku.py. Also print puzzle status if execution is interrupted. --- assignments/archive/sudoku/soln/sudoku.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/assignments/archive/sudoku/soln/sudoku.py b/assignments/archive/sudoku/soln/sudoku.py index 126664f..2c08697 100755 --- a/assignments/archive/sudoku/soln/sudoku.py +++ b/assignments/archive/sudoku/soln/sudoku.py @@ -225,7 +225,7 @@ class Sudoku (object): actions = 0 while True: - start_actions = 0 + start_actions = actions for row in range(9): for col in range(9): if self._puzzle[row][col] == self._empty: @@ -260,6 +260,9 @@ if __name__ == '__main__': s = Sudoku() puzzle = sys.stdin.read() s.load(puzzle) - s.solve() + try: + s.solve() + except KeyboardInterrupt, e: + s.status = 'interrupted' print >> sys.stderr, s.status print s.dump() -- 2.26.2