uk.co.keang.sudoku
Class SudokuSolver

java.lang.Object
  extended by uk.co.keang.sudoku.SudokuSolver

public class SudokuSolver
extends java.lang.Object

A Sudoku puzzle solver

Author:
A.G.Docherty

Field Summary
static int GRID_SIZE
           
static int SUB_GRID_SIZE
           
 
Constructor Summary
SudokuSolver()
           
SudokuSolver(java.lang.String[] args)
           
 
Method Summary
 void addSolverListener(SolverListener listener)
          Adds a solver listener to all solvers
(package private)  int compute()
          Runs the solvers
 Puzzle getPuzzle()
          Gets the puzzle
 SequenceBuffer getSequenceBuffer()
           
(package private)  boolean isInBounds(int num)
          Checks the value is between 1 and GRID_SIZE inclusive
static void main(java.lang.String[] args)
           
(package private)  void print()
          dumps a formatted view of resolved values to the screen
 void printDetail()
          Dumps a formatted view of possible values for each cell to the screen
 void removeSolverListener(SolverListener listener)
          Removes the solver listener from all solvers
 void setPuzzle(Puzzle p)
          Sets the solvers puzzle grid to this puzzles grid
 void setSequenceBuffer(SequenceBuffer buf)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SUB_GRID_SIZE

public static final int SUB_GRID_SIZE
See Also:
Constant Field Values

GRID_SIZE

public static final int GRID_SIZE
See Also:
Constant Field Values
Constructor Detail

SudokuSolver

public SudokuSolver()

SudokuSolver

public SudokuSolver(java.lang.String[] args)
Method Detail

getPuzzle

public Puzzle getPuzzle()
Gets the puzzle

Returns:
the puzzle

setPuzzle

public void setPuzzle(Puzzle p)
Sets the solvers puzzle grid to this puzzles grid

Parameters:
the - puzzle

isInBounds

boolean isInBounds(int num)
Checks the value is between 1 and GRID_SIZE inclusive

Parameters:
num -
Returns:

compute

int compute()
      throws IllegalGridException
Runs the solvers

Returns:
the difficulty where a higher number denotes a more difficult puzzle
Throws:
IllegalGridException

addSolverListener

public void addSolverListener(SolverListener listener)
Adds a solver listener to all solvers

Parameters:
listener - - the listener to add

removeSolverListener

public void removeSolverListener(SolverListener listener)
Removes the solver listener from all solvers

Parameters:
listener - - the listener to remove

printDetail

public void printDetail()
Dumps a formatted view of possible values for each cell to the screen


print

void print()
dumps a formatted view of resolved values to the screen


getSequenceBuffer

public SequenceBuffer getSequenceBuffer()

setSequenceBuffer

public void setSequenceBuffer(SequenceBuffer buf)

main

public static void main(java.lang.String[] args)