-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdivision.py
30 lines (27 loc) · 932 Bytes
/
division.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
class Division:
def __init__(self):
self._cells = []
def add_cell(self, cell):
self._cells.append(cell)
def find_cells_for_values(self):
make_difference = False
for value in range(1, 10):
found = False
value_cells = []
for cell in self._cells:
if found:
break
if cell.value == value:
found = True
if cell.value is not None:
continue
if value in cell.possible_values:
value_cells.append(cell)
if found:
continue
if len(value_cells) == 0:
raise ValueError(f"Cannot find cell for value {value}")
if len(value_cells) == 1:
value_cells[0].set_value(value)
make_difference = True
return make_difference