From cc5e35ff8194ee29390b86a14255b95a11348f5b Mon Sep 17 00:00:00 2001 From: Eryn Wells Date: Fri, 30 Aug 2013 10:11:44 -0700 Subject: [PATCH] Working on search() --- sudoku.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sudoku.py b/sudoku.py index ea78cc2..ea1bbd8 100644 --- a/sudoku.py +++ b/sudoku.py @@ -135,6 +135,14 @@ class Board(dict): raise return self.solved + def search(self): + if self.solved: + return True + + # Chose the square with the fewest possible values. + _, smallest = min((len(self[sq]), sq) for sq in self if len(self[sq]) > 1) + # Deepcopy the board. + def assign(self, square, value): ''' Assign {value} to {square}. {value} is expected to be an iterable (a list). {key} should be a valid (x, y)