clearscreen() # building the blank sudoku table sudoku = Table() # Having the user enter the sudoku puzzle sudoku.get_table() print("This is your sudoku puzzle:") print(sudoku) num = 1 row = 0 col = 0 counter = 0 max_tries = 1000 # This will loop through while the puzzle isn't solved, or until it's # reached the maximum tries. while sudoku.puzzle_has_blanks() and counter < max_tries: for num in range(10): # this will cause it to iterate through the sectors in the grid for sector_id in range(9): # setting the number of flagged/possible spots to 0 sudoku.flagged_spots = 0 # the massive if statements that looks at a box in the puzzle to # determine if those things are all true. for number_in_block, row, col in sudoku.iter_sector(sector_id): if (sudoku.current_box_is_blank(row, col) and sudoku.num_is_not_in_sector(row, col, num) and sudoku.num_is_not_in_row(row, col, num) and sudoku.num_is_not_in_col(row, col, num)): # if all are true, it flags that spot as a possible # solution, and records it. sudoku.flagged_spots += 1