Package algs13.xbacktrack.xsudoku
Class MySudoku
java.lang.Object
algs13.xbacktrack.xsudoku.MySudoku
- All Implemented Interfaces:
XBacktrackProblem<algs13.xbacktrack.xsudoku.XMutableCell>
public final class MySudoku
extends Object
implements XBacktrackProblem<algs13.xbacktrack.xsudoku.XMutableCell>
A Sudoker solver, implemented as a BacktrackProblem where each
choice is represented by a MutableCell (a cell we can assign a
digit as part of a possible solution to Sudoku).
This project represents a more substantial Java program than
what we have been working with so far in the course. Search in this
file and in algs13.xbacktrack.xframework.MyBacktrackDriver
(MyBacktrackDriver.java)for some TODOs that will direct you to what you
need to do for this assignment.
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
advance
(algs13.xbacktrack.xsudoku.XMutableCell previous) Determine if the backtracking driver can advance in searching for a solution from the state represented by previous choice.void
initialize
(MyBacktrackDriver<algs13.xbacktrack.xsudoku.XMutableCell> driver) Initialize the problem.static void
toString()
-
Field Details
-
SUBGRID_DIMENSION
- See Also:
-
GRID_SIZE
- See Also:
-
-
Method Details
-
initialize
Description copied from interface:XBacktrackProblem
Initialize the problem. The initialize method must call the track method on the driver to track the starting state.- Specified by:
initialize
in interfaceXBacktrackProblem<algs13.xbacktrack.xsudoku.XMutableCell>
- Parameters:
driver
- The driver orchestrating the search for the solution.
-
advance
Description copied from interface:XBacktrackProblem
Determine if the backtracking driver can advance in searching for a solution from the state represented by previous choice. If it can, this method must either call the track method on the driver to track the next choice, or it must call the driver's setDone() method.- Specified by:
advance
in interfaceXBacktrackProblem<algs13.xbacktrack.xsudoku.XMutableCell>
- Parameters:
previous
- The previous choice- Returns:
- true if the current state consists of a valid partial solution, or the current state represents a complete solution (i.e. the last choice required to solve the problem has been made).
-
toString
-
main
-