Results 1 to 15 of 15

Thread: Number of Unique Solutions to an Empty Sudoku Puzzle

Threaded View

  1. #8
    Only Slightly Obsessive jemidiah's Avatar
    Join Date
    Apr 2002
    Posts
    2,431

    Re: Number of Unique Solutions to an Empty Sudoku Puzzle

    I figure there's some set of a few operations you can perform to solve any uniquely solvable Sudoku, and I bet there's been a lot of research into that too. At the least advanced elimination methods can be used to solve most of the "difficult" ones out there.

    You can brute force it as well, recursively guessing once all other options are exhausted until you either get a contradiction or finish the puzzle.

    The recursive method would be incredibly simple, actually, something like this:

    Code:
    'SolveSudoku prints every possible solution to the given Sudoku if it is solvable. If it is unsolvable, function does nothing.
    function SolveSudoku(ByVal Sudoku)
        SolveButDontGuess(Sudoku)
    
        If Complete(Sudoku) Then Print(Sudoku) 'Base case 1
        If Contradiction(Sudoku) Then Exit Function 'Base case 2
        
        If Incomplete(Sudoku) Then 'Recusive case
            Guesses = GetGuesses(Sudoku)
            For Each Guess in Guesses
                MakeOneGuess(Sudoku, Guess)
                SolveSudoku(Sudoku)
                UndoOneGuess(Sudoku, Guess)
            End If
        End If
    end
    This sorta makes me want to write a Sudoku solver to see how inefficient this method is. But not enough to actually write it . Writing a good SolveButDontGuess function is really the guts of the problem, the rest is all pretty basic. Even GetGuesses is simple enough if your SolveButDontGuess function does some sort of elimination routine that gives a list of valid number placements.
    Last edited by jemidiah; Aug 2nd, 2008 at 02:54 AM.
    The time you enjoy wasting is not wasted time.
    Bertrand Russell

    <- Remember to rate posts you find helpful.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width