import re
from weakref import ref
-from cellgroup import CellConstraint, Row, Column, Box
+from constraints import Constraint, Row, Column, Box
symbols = [str(x + 1) for x in range(9)] + [chr(x + 97) for x in xrange(26)]
### Accessors
- def get_constraints(self, constraint_class=CellConstraint):
+ def get_constraints(self, constraint_class=Constraint):
"""Returns constraints of a certain type. Returns all of them by
default.
"""
from weakref import ref
-class CellConstraint(object):
+class Constraint(object):
"""Represents any group of cells in a grid that cannot repeat a digit."""
### Accessors
target_cell.set(value)
-class Box(CellConstraint):
+class Box(Constraint):
def _get_box_row(self):
return self._pos // self.grid._box_width
box_row = property(_get_box_row)
self._cells.append(ref(self.grid.cell(cell_row, cell_col)))
-class Row(CellConstraint):
+class Row(Constraint):
def __init__(self, grid, position):
self._grid = ref(grid)
self._pos = position
for col in xrange(self.grid._size):
self._cells.append(ref(self.grid.cell(self._pos, col)))
-class Column(CellConstraint):
+class Column(Constraint):
def __init__(self, grid, position):
self._grid = ref(grid)
self._pos = position
for row in xrange(self.grid._size):
self._cells.append(ref(self.grid.cell(row, self._pos)))
-class Diagonal(CellConstraint):
+class Diagonal(Constraint):
def __init__(self, grid, direction='down', offset=0):
self._grid = ref(grid)
self._direction = direction