-1
I am transcribing from Java to Python a code to solve a Sudoku 4/4.
When I test the code it doesn’t run and runs endlessly, apparently in one of the methods of the Artist class. Can someone help me find the mistake?
import random
class Artista:
__caracteristicas = list(range(0,4))
def __init__(self):
self.gerar_caracteristicas_artista()
def gerar_caracteristicas_artista(self):
aux = random.randrange(0,4) + 1
for i, v in enumerate(self.__caracteristicas):
while self.__verifica_repeticao(aux):
aux = random.randrange(0,4) + 1
self.__caracteristicas[i] = aux
def __verifica_repeticao(self,valor):
for i, v in enumerate(self.__caracteristicas):
if valor == v:
return True
return False
def imprime_caracteristicas(self):
print(self.__caracteristicas)
def get_caracteristicas(self):
return self.__caracteristicas from sudoku import Artista class Grupo:
__artistas = list(range(0,4))
def __init__(self):
artista1 = Artista.Artista()
artista2 = Artista.Artista()
artista3 = Artista.Artista()
artista4 = Artista.Artista()
self.__artistas.clear()
self.__artistas = [artista1,artista2,artista3,artista4]
def imprime_artistas(self):
for i in self.__artistas:
self.__artistas[i].imprime_caracteristicas()
print('\n') from sudoku import Grupo
class Sudoku:
grupo= Grupo.Grupo()
grupo.imprime_artistas()
has some things in its code that ñ recognize how it works '''def get_characteristics(self): Return self. __characteristics from sudoku import Artist class Group: __artists = list(range(0,4))''' how this part works?
– Elton Nunes