def test_rotate_clockwise(self): lines = board.get_lines("sudoku_boards/hardest.txt") for line in lines: game_board = board.convert_str_to_2d_board(line.replace("\n", "")) generator.rotate_clockwise(game_board) result = solver.solve_sudoku(game_board, False) self.assertEqual(result, True)
def test_switch_numbers(self): lines = board.get_lines("sudoku_boards/hardest.txt") for line in lines: game_board = board.convert_str_to_2d_board(line.replace("\n", "")) for _ in range(10): generator.switch_numbers(game_board, randint(1, 9), randint(1, 9)) result = solver.solve_sudoku(game_board, False) self.assertEqual(result, True)
def test_switch_block_row(self): lines = board.get_lines("sudoku_boards/hardest.txt") for line in lines: game_board = board.convert_str_to_2d_board(line.replace("\n", "")) for _ in range(10): index1 = randint(0, 2) index2 = randint(0, 2) generator.switch_block_row(game_board, index1, index2) result = solver.solve_sudoku(game_board, False) self.assertEqual(result, True)
def test_hardest(self): lines = board.get_lines("sudoku_boards/hardest.txt") self.check(lines)
def test_easy5(self): lines = board.get_lines("sudoku_boards/easy5.txt") self.check(lines)
def get_base_grid(): unsolved_lines = get_lines("sudoku_boards/easy5.txt") index = randint(0, len(unsolved_lines) - 1) grid = convert_str_to_2d_board(unsolved_lines[index]) return grid