From: W. Trevor King Date: Tue, 12 Oct 2010 12:29:42 +0000 (-0400) Subject: Fix "failed to solve" comparison in sudoku.py. X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=8ba885f061d3c46c964e5f1715abd8f6c131f7c7;p=parallel_computing.git Fix "failed to solve" comparison in sudoku.py. Also print puzzle status if execution is interrupted. --- 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()