From 9065fe89fb6f81e7c358100e9127349c27bbb4f4 Mon Sep 17 00:00:00 2001 From: Eevee Date: Wed, 17 Dec 2008 00:44:09 -0800 Subject: [PATCH] Replaced set_naively with set(normalize=False). --- pseudoku/grid/__init__.py | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/pseudoku/grid/__init__.py b/pseudoku/grid/__init__.py index 9370dd6..94d0833 100644 --- a/pseudoku/grid/__init__.py +++ b/pseudoku/grid/__init__.py @@ -63,18 +63,14 @@ class Cell(object): self._values = range(self._grid.size) self._normalized = False - def set_naively(self, value): - """Sets the value of this cell, WITHOUT eliminating the value from - every other cell in its row/column/box. + def set(self, value, normalize=True): + """Sets the value of this cell. If `normalize` is True or omitted, the + grid will be updated accordingly. """ - self._values = [value] - - def set(self, value): - """Sets the value of this cell and adjusts the grid accordingly.""" - self.set_naively(value) - self._normalized = False - self.normalize() + if normalize: + self._normalized = False + self.normalize() @@ -214,7 +210,7 @@ class Grid(object): value = rows[row][col] if not value: continue - self.cell(row, col).set_naively(value - 1) + self.cell(row, col).set(value - 1, normalize=False) return self @@ -253,7 +249,7 @@ class Grid(object): ch = grid[ self._cellidx(row, col) ] if ch == '0': continue - self.cell(row, col).set_naively(symbols.index(ch)) + self.cell(row, col).set(symbols.index(ch), normalize=False) return self -- 2.7.4