-
Notifications
You must be signed in to change notification settings - Fork 0
/
Cell.py
46 lines (38 loc) · 1.24 KB
/
Cell.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
from RowColumn import RowColumn
class Cell:
letter = None
number = None
box = None
row = None
column = None
validValues = None
rowColumnLength = None
def __init__(self, letter, number, box, rowColumnLength):
self.letter = letter
self.number = number
self.box = box
self.rowColumnLength = rowColumnLength
def assignValue(self, value):
if self.isValueValid(value):
self.number = value
self.row.addValue(value)
self.column.addValue(value)
return True
return False
# def bestAssignValue(self, value):
# if self.bestIsValueValid(value):
# self.number = value
# self.row.addValue(value)
# self.column.addValue(value)
# return True
# return False
# def bestRemoveValue(self, value):
# self.number = 0
# self.row.removeValue(value)
# self.column.removeValue(value)
def removeValue(self, value):
self.number = 0
self.row.removeValue(value)
self.column.removeValue(value)
def isValueValid(self, value):
return self.row.isValueValid(value) and self.column.isValueValid(value) and self.box.isValueValid(value)