def test_las_vegas(self): board = generate_terminal_pattern() # Test the generated board is valid. self.assertIsNotNone(board) self.assertTrue(board.is_valid()) # Test board doesn't have any empty cells. for i in xrange(0,9): for j in xrange(0,9): self.assertTrue(board.get(i, j) != 0)
def generate_sudoku_with_unique_solution(difficulty): """Generates a partially completed sudoku with a unique solution, of the given difficulty (1 through 5).""" # Generate a terminal pattern (fully completed sudoku) terminal_pattern = generate_terminal_pattern() # Instantiate a Digger instance for the selected difficulty. digging_strategy = DiggingStrategy(difficulty) digger = Digger(digging_strategy) sudoku = digger.dig_cells(terminal_pattern) return sudoku
def setUp(self): digging_strategy = DiggingStrategy(1) self.digger = Digger(digging_strategy) self.terminal_pattern = generate_terminal_pattern()