code: def solve(self, verbose=False, allow_brute_force=True):
          
          while not self.is_solved:
              # Update possibles arrays.
              self._update()
  
              # See if any position can be singled out.
              singles_found = False or self._fill_naked_singles() or self._fill_hidden_singles()
  
              # If singles_found is False, then no new uniquely defined cells were found
              # and this solver cannot solve the Sudoku. We either use brute force or throw an error.
              # Else, if singles_found is True, run another iteration to see if new singles have shown up.
              if not singles_found:
                  if allow_brute_force:
                      solution = None
                      try:
                          dlxs = DancingLinksSolver(copy.deepcopy(self._matrix))
                          solutions = dlxs.solve()
                          solution = next(solutions)
                          more_solutions = next(solutions)
                      except StopIteration as e:
                          if solution is not None:
                              self._matrix = solution
                          else:
                              raise SudokuHasNoSolutionError("Dancing Links solver could not find any solution.")
                      except Exception as e:
                          raise SudokuHasNoSolutionError("Brute Force method failed.")
                      else:
                          # We end up here if the second `next(solutions)` works,
                          # i.e. if multiple solutions exist.
                          raise SudokuHasMultipleSolutionsError("This Sudoku has multiple solutions!")
                      self.solution_steps.append("BRUTE FORCE - Dancing Links")
                      break
                  else:
                      print(self)
                      raise SudokuTooDifficultError("This Sudoku requires more advanced methods!")
          if verbose:
              print("Sudoku solved in {0} iterations!\n{1}".format(len(self.solution_steps), self))
              for step in self.solution_steps:
                  print(step)
docs: Solve the Sudoku.
  
          :param verbose: If the steps used for solving the Sudoku
                          should be printed. Default is `False`
          :type verbose: bool
          :param allow_brute_force: If Dancing Links Brute Force method
                                    should be used if necessary. Default is `True`
          :type allow_brute_force: bool