instructions


Yet another...   Sudoku Solver

Your browser does not support Java, so nothing is displayed.



FAQ
 
 
"So what is it?"   It's a Sudoku Solver. It solves Sudoku puzzles.
 
"What is a Sudoku?"   Well the definition of sudoku given by wikipedia is the following:

"Sudoku sometimes spelled Su Doku, is a logic-based placement puzzle, also known as Number Place in the United States. The aim of the canonical puzzle is to enter a numerical digit from 1 through 9 in each cell of a 9x9 grid made up of 3x3 subgrids (called "regions"), starting with various digits given in some cells (the "givens"). Each row, column, and region must contain only one instance of each numeral. Completing the puzzle requires patience and logical ability. Its grid layout is reminiscent of other newspaper puzzles like crosswords and chess problems or griddlers. Although first published in 1979, Sudoku initially caught on in Japan in 1986 and attained international popularity in 2005."
 
"Aren't there a ton of these all over the net?"   Yeah.
 
"So what's good about this one?"   I made it.
 
"Anything else?"   Sure, unlike most other sudoku solvers mine does not solve sudokus by brute force.
 
"Brute force sounds good, why not?"   Well, if this sudoku solver used brute force to solve sudoku puzzles it would be neglecting the fact that humans use human logic to solve sudokus.
 
"Human logic?"   Yes, normaly sudokus are solved by logicaly reasoning about which cells or fields in the sudoku must be filled by some value. This logical reasoning can be done by elimination. That is discovering which cells cannot for some reason contain the value. If at some point only one square is availible in a row, column or region then that value must be the appropriate choice for the cell in question.
 
"So it thinks like humans, what's so great about that?"   It's good because it can then provide meaningfull information to human users, helping them understand how the solution could be found by a succession of logical steps. This is in stark contrast to simply providing a final answer through exhaustive search by brute force.
 
"Meaningfull information?"   By steping through a puzzle either manualy or using the automated play functionality the sudoku solver will display a possible next step towards the solution. It displays this by:
  1. Highlighting the current value being reviewed.
  2. Highlighting the row, column and region for which the sudoku invariants must be upheld with regard to the cell which can be filled.
  3. Crossing out all cells which are open in the row column and region for for which the sudoku invariants must be upheld with regard to the cell but cannot for some reason be filled with the value in question.
In other words it shows the succession of steps which provide the final solution by logicaly deducing where values can be placed at each step, like a human would.
 
"Ok, but how do I use the sudoku solver? What if I want it to solve some other sudoku?"   The sudoku solver is primarialy controlled via. the graphical user interface in addition to some features also being supported by keyboard imput.

Graphical User Interface:
  • Input:

    To place a value on the board, first select a value using the radioboxes on the top right-hand side of the sudoku solver. Then use your mouse to place it on the board by clicking in the cell you wish to place it in. To delete a value select the radiobox marked by 'c' for clear and use your mouse to select the relevant cell to clear.
     
  • Algorithm Control:

    In the bottom of the sudoku solver select the tab marked by 'algorithm'.

    • step can be used to incrementaly step through the sudoku towards the solution.
    • play can be used to incrementaly step through the sudoku automaticaly with a time delay between each step.
    • stop is used to stop the automatic play functionality.
    • solve can be used to instantly solve the puzzle and show the solution.
    • The slider is used to indicate how fast the play functionality should commence.

     
  • History:

    In the bottom of the sudoku solver select the tab marked by 'history'.

    • save can be used to save the current state of the board internaly in the sudoku solver (this does not save the state to a file on your computer). This is usefull if you later want to use reset.
    • reset can be used to reset the state of the board to the state most recently saved by save.
    • clear can be used to clear all cells on the board.
    • load is unsupported at this time.

     
  • Board Appearance:

    In the bottom of the sudoku solver select the tab marked by 'appearance'.

    • highlight can be used to highlight the state of eliminated cells on the board for some value. Before using highlight select the value which you want highlight information displayed on the board for by using either the radiobuttons on the right-hand side or via keyboard input.
Keyboard:
  • Cursor:

    To make use of keyboard input it is necissary to be able to mark which cell the input should effect. This is done by moving a cursor around the board using the arrow keys on your keyboard. The cursor disappears after 2 seconds of inactivity but remains located where it was last moved to. The cursor can also be moved using the mouse.
     
  • Input:

    To input via. the keyboard move the cursor as described above to the desired cell and then type the number you wish to place in the cell. Both the numbers at the top of your keyboard and the numpad can be used. If you wish to clear a cell either use the key 'c', backspace or delete.
     
  • Cursor Mode / Select Mode

    When using the graphical user interface in combination with the keyboard it is somtimes convenient that value input simply changes which value is currently selected. If this is desired use the space button to change to select mode at which point keyboard input no longer effects the board. To change back to cursor mode simply hit the space bar again.
 
"This is all great, but how am i supposed to understand how it eliminates cells?"   At any point one can utilize the 'highligh' button located under the 'appearance' tab to display infomation about the current state of eliminated fields on the board. It will display relevant information by using three symbols in three variations of colors to mark a field eliminated for the value selected in the radio buttons on the right hand side of the sudoku solver.

The Symbols used are:
 
This symbol is used when a cell has been eliminated based on the sudoku 3x3 region invariants
 
This symbol is used when a cell has been eliminated based on the sudoku column invariants
 
This symbol is used when a cell has been eliminated based on the sudoku row invariants

The Colors used are:
 
This color is used when a cell is elimented by elementary deduction. That is, placing the value in such a cell would invalidate one of the sudoku row, column or region invariants.
 
This color is used when a cell is elimented by implicit deduction. That is, the cell cannot be filled with the value in question because the state of the board dictates that the value must be placed in some other part of the row, value or region based on the sudoku invariants.
 
This color is used when a cell is elimented by exclusive deduction. That is, there is a subset of values equal to the number of cells which these values must occupy to fulfill one of the row, column or region sudoku invariants. Logicaly the complement set of the subset of values which must occupy the cells cannot occupy these cells. Thus the complement set can eliminate these cells

This is exactly same amount of information which the algorithm has at its disposal. It is also simple to discover which cells can at some step in a puzzle be filled by a certain value. Simply look for single empty cells in a row, column or region. That is all other fields must be eliminated by one of the above symbols and a single field remains.
 
"Isn't it possible that a cell can be eliminated by multiple of the above logical deductions at the same time?"   This is true. It is entirerly possible that a cell can be both eliminated by elementary, implicit and exclusive deduction at the same point in the solution of the puzzle. However it is also completely legal in the sence that this does not violate the sudoku invariants. In such a case the 'highlight' ability of the sudoku solver will prioritize the logical deductions (just as it does in the course of the algorithm) as follows:
  1. Elementary Square
  2. Elementary Column
  3. Elementary Row
  4. Implicit Square
  5. Implicit Column
  6. Implicit Row
  7. Exclusive Square
  8. Exclusive Column
  9. Exclusive Row
 
"Aren't there any drawbacks to using logical deduction instead of exhaustive search by brute force?"   Yes. The most severe drawback is the fact that any sudoku solver based on logical deduction will not be able to solve all sudoku puzzles. This is unfortunately true because it is possible to construct a legal sudoku that at some point requires an entirerly random guess in order to move forward. It has actualy been proven that sudoku puzzles are NP-complete since they can be reduced to the graph coloring problem. This means that it is extreemely unlikely that there exists a polynomial time algorithm in the size of the sudoku puzzle which can solve it.
Thus a brute force algorithm is superior in the sence that it will find a solution to any legal sudoku puzzle since it essentialy guesses its way to a solution. However such sudoku puzzles are in a practical sence irrelevant because they are too difficult to be solved by a human since humans do not use exhaustive search by brute force.