-
Notifications
You must be signed in to change notification settings - Fork 0
/
SudokuTable.py
49 lines (40 loc) · 1.5 KB
/
SudokuTable.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
47
48
49
class SudokuTable:
# region Constructor
def __init__(self, tableSize, regionSize):
if tableSize in [4, 9, 16, 25]:
print("Table size is: ", tableSize)
else:
raise ValueError("Bad tableSize and regionSize")
self._regionSize = regionSize
self._tableSize = tableSize
self._fieldValues = []
for _ in range(tableSize):
self._fieldValues.append([0]*tableSize)
self._OriginValues = []
for _ in range(tableSize):
self._OriginValues.append([0]*tableSize)
# endregion
# region Table methods
def IsFilled(self):
for value in self._fieldValues:
for item in value:
if item == 0:
return False
return True
def RegionSize(self):
return self._regionSize
def Size(self):
return int(len(self._fieldValues))
def IsEmpty(self, x, y):
if x < 0 or x >= len(self._fieldValues):
raise ValueError("The X coordinate is out of range")
if y < 0 or y >= len(self._fieldValues):
raise ValueError("The Y coordinate is out of range")
return self._fieldValues[x][y] == 0
def GetValue(self, x, y):
if x < 0 or x >= len(self._fieldValues):
raise ValueError("The X coordinate is out of range")
if y < 0 or y >= len(self._fieldValues):
raise ValueError("The Y coordinate is out of range")
return self._fieldValues[x][y]
# endregion