ich komme gerade nicht auf den Fehler wieso ich bei einem Sudokufeld in eine Endlosschleife komme...
Ich Überprüfe nur ob die gewählte Zahl bereits in Zeile und Spalte vorhanden ist... Trotzdem scheint es nicht zu funktionieren
Code: Alles auswählen
def isInRow(self, row, value):
hlp = False
for i in range(self.__maxLength__):
if ( self.m[row][i] == value ):
hlp = True
return hlp
def isInColumn(self, column, value):
hlp = False
for i in range(9):
if ( self.m[i][column] == value ):
hlp = True
return hlp
def isIn3x3Matrix(self, value):
count = 3
hlp = False
while(count <= self.__maxLength__):
for i in range(count):
for j in range(count):
if (self.m[i][j] == value):
hlp = True
count += 3
return hlp
def createField(self):
for i in range(self.__maxLength__):
for j in range(self.__maxLength__):
randInt = random.randint(1,9)
while(self.isInRow(i,randInt) == True | self.isInColumn(j,randInt == True)):
randInt = random.randint(1,9)
self.setAttribut(i,j,0)
self.setAttribut(i,j, randInt)