This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def __generator__(self, grid, i, j): | |
number = [1, 2, 3, 4, 5, 6, 7, 8, 9] | |
if j > 8: | |
j = 0 | |
i += 1 | |
# end condition | |
if i > 8: | |
return True | |
# skipping cell if the cell has already a number |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def __solve_backtrack__(self, i, j, visualize=False): | |
# Changing row if col index reaches end of the row | |
if j > 8: | |
j = 0 | |
i += 1 | |
# end condition | |
if i > 8: | |
if visualize == False: | |
eel.draw_sudoku(self.sudoku_solved) | |
return True |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def validate_cell(self, sudoku_solved, val, i, j): | |
# getting index for block ( 9 blocks of 3x3 size) | |
block_i = i // 3 | |
block_j = j // 3 | |
# check block | |
for b_i in range(block_i * 3, block_i * 3 + 3): | |
for b_j in range(block_j * 3, block_j * 3 + 3): | |
if sudoku_solved[b_i][b_j] == val: | |
return False |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
NewerOlder