|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.hadoop.examples.dancing.Pentomino
public class Pentomino
| Nested Class Summary | |
|---|---|
protected static interface |
Pentomino.ColumnName
This interface just is a marker for what types I expect to get back as column names. |
protected static class |
Pentomino.Piece
Maintain information about a puzzle piece. |
static class |
Pentomino.SolutionCategory
|
| Field Summary | |
|---|---|
protected static int[] |
fourRotations
Are all 4 rotations unique? |
protected int |
height
|
protected static int[] |
oneRotation
Is the piece fixed under rotation? |
protected List<Pentomino.Piece> |
pieces
|
protected static int[] |
twoRotations
Is the piece identical if rotated 180 degrees? |
protected int |
width
|
| Constructor Summary | |
|---|---|
Pentomino()
Create the object without initialization. |
|
Pentomino(int width,
int height)
Create the model for a given pentomino set of pieces and board size. |
|
| Method Summary | |
|---|---|
Pentomino.SolutionCategory |
getCategory(List<List<Pentomino.ColumnName>> names)
Find whether the solution has the x in the upper left quadrant, the x-midline, the y-midline or in the center. |
List<int[]> |
getSplits(int depth)
Generate a list of prefixes to a given depth |
protected void |
initializePieces()
Fill in the pieces list. |
static void |
main(String[] args)
Solve the 6x10 pentomino puzzle. |
void |
setPrinter(DancingLinks.SolutionAcceptor<Pentomino.ColumnName> printer)
Set the printer for the puzzle. |
int |
solve()
Find all of the solutions to the puzzle. |
int |
solve(int[] split)
Find all of the solutions that start with the given prefix. |
static String |
stringifySolution(int width,
int height,
List<List<Pentomino.ColumnName>> solution)
Convert a solution to the puzzle returned by the model into a string that represents the placement of the pieces onto the board. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected int width
protected int height
protected List<Pentomino.Piece> pieces
protected static final int[] oneRotation
protected static final int[] twoRotations
protected static final int[] fourRotations
| Constructor Detail |
|---|
public Pentomino(int width,
int height)
width - the width of the board in squaresheight - the height of the board in squarespublic Pentomino()
| Method Detail |
|---|
public static String stringifySolution(int width,
int height,
List<List<Pentomino.ColumnName>> solution)
width - the width of the puzzle boardheight - the height of the puzzle boardsolution - the list of column names that were selected in the model
public Pentomino.SolutionCategory getCategory(List<List<Pentomino.ColumnName>> names)
names - the solution to check
protected void initializePieces()
public List<int[]> getSplits(int depth)
depth - the length of each prefix
public int solve(int[] split)
split - a list of row indexes that should be choosen for each row
in order
public int solve()
public void setPrinter(DancingLinks.SolutionAcceptor<Pentomino.ColumnName> printer)
printer - A call-back object that is given each solution as it is
found.public static void main(String[] args)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||