C’est la méthode de oop pour résoudre le Sudoku.
Une chaîne de deux positions au-dessus et qui ne sont pas dans la même boîte, mais dans la même ligne, et peuvent former une chaîne, désigne le nombre possible de cette chaîne positions ne peut être remplie à ces positions
Un tableau d’un Sudoku
get the possition list which can see the position, p method: “u”: un-assigned positions, “a”: all, “s”: assigned positions num: if method=”u”, the position must have be possible to be filled the number
reduce the position(x, y)’s possible numbers from v Return:
int, as following
2 -- if set a number,
1 -- if just set number
0 -- if is not in the possible set, if check is True, it will raise an SudokuError exception
nombre d’objets
Une position à la table d’un Sudoku
Une exception Lorsque le tableau a été rempli 81 postes
Une exception lorsque x, y ne peuvent pas être réglés ou réduire ou forment le nombre vt: est le type: ‘s’ signifie ensemble, «r» signifie réduire
Une exception Lorsque le numéro d’enregistrement = recLimit
Une exception Lorsque la position, checkPos, a été défini, et le programme veulent SETIT
Check every number which has been assigned and known as group-number and its effect’s boxes’ does not have assigned that number” Only: False, check all numbers
True, check the first number only
first: the first number to be checked
Vérifiez chaque ligne qui ont une seule position pour le nombre de non affecté
Check every number which has been assigned and its effect’s boxes’ does not have assigned that number Only: False, check all numbers
True, check the first number only
first: the first number to be checked
comparer la liste des résultats, afin de vérifier s’il ya même résultat à chaque étape après le dernier enregistrement de m.rec original si même pour tous imiter résultat, cela signifie qu’il doit être vrai, ne peut donc faire par elle
emulate the x, y to be set v, then start to use some basic methods to try to solve it will stop when and return 1: one of the targets have been set the checkval 2: isDone -1: error is True 0: all basic methods have been tested, and can’t solve and the result matrix
When setting a number, may cause 1-3 groups left only one possible position check if a group have only position left, just set it
Si les positions non assignées à un groupe (ligne ou boîte) sont une seule gauche
Consultez toutes les positions non affecté, si c’est possible numéros gauche on ne WRITEN_POSSIBLE_LIMIT: C’est vrai, Vérifier la writen de position est vraie ou fausse note, ne cochez pas.
when a position(p1) has 2 or more possible numbers, we can emulate every possible number and get its result, 1. if it causes an error, we can reduce that number, 2. if it can solve the sudoku, we can set this number, 3. if all possible number can’s get condition 1 or 2, we can compare their rec, if they have the same records, we can do it.
when a group(lineX, lineY, Box) has 2 or more position have the same possible number, we can emulate every position to set the number and get its result, 1. if it causes an error, we can reduce the position’s possible number from that number, 2. if it can solve the sudoku, we can set this number in the position, 3. if all possible position can’s get condition 1 or 2, we can compare their rec, if they have the same records, we can do it.
Réduire le nombre possible dans une posiition par GroupNumber
quand une position (p1) ne dispose que de deux nombres possibles, nous pouvons supposer que la position est un nombre (en premier), puis essayer d’imiter pour définir la position de l’autre numéro (deuxième), puis voir le premier numéro sera rempli dans un position (P2) qui la position peut voir si c’est le cas, nous pouvons réduire toutes ces positions qui peuvent voir P1 et P2 dans le même temps du premier numéro
enregistrer toutes les méthodes comme un objet et de les enregistrer dans une liste de revenir
Check is there an more obvious method for the position, p1 than method1 Obvious methods include fillLastPostionOfGroup=0 and checkObviousNumber=1 return: True: set, False: not set
Solve a sudoku which define in a file! loopLimit: the limit for the method loops, 0: no limits recLimit: when the records >= recLimit, it will stop, 0: no limits
Try Error Method, only fill the first possible postion
Mettre à jour la chaîne de retour à la ligne: = 0 signifie le montant du numéro de chaîne dans la matrice, m
Update the group number, num, in a box, and store those group number in m.n.group list return: >=0 means the group number’s amount in the matrix, m