@Test public void testSolveWithOneStep() { GameMatrix matrix = Creator.createFull(); Random random = new Random(); int row = random.nextInt(9); int column = random.nextInt(9); RiddleImpl riddle = new RiddleImpl(); riddle.setAll(matrix.getArray()); riddle.set(row, column, GameMatrix.UNSET); riddle.setWritable(row, column, true); Solver solver = new Solver(riddle); List<GameMatrix> solutions = solver.solve(); assertEquals(1, solutions.size()); assertEquals(matrix, solutions.get(0)); }
public List<GameMatrix> solve() { possibleSolutions.clear(); int freeCells = GameMatrix.TOTAL_FIELDS - riddle.getSetCount(); backtrack(freeCells, new int[2]); return Collections.unmodifiableList(possibleSolutions); }
Solver { public List<GameMatrix> solve() { possibleSolutions.clear(); int freeCells = GameMatrix.TOTAL_FIELDS - riddle.getSetCount(); backtrack(freeCells, new int[2]); return Collections.unmodifiableList(possibleSolutions); } }
Solver { public List<GameMatrix> solve() { possibleSolutions.clear(); int freeCells = GameMatrix.TOTAL_FIELDS - riddle.getSetCount(); backtrack(freeCells, new int[2]); return Collections.unmodifiableList(possibleSolutions); } Solver(final GameMatrix solveMe); }
Solver { public List<GameMatrix> solve() { possibleSolutions.clear(); int freeCells = GameMatrix.TOTAL_FIELDS - riddle.getSetCount(); backtrack(freeCells, new int[2]); return Collections.unmodifiableList(possibleSolutions); } Solver(final GameMatrix solveMe); void setLimit(final int set); List<GameMatrix> solve(); }
Solver { public List<GameMatrix> solve() { possibleSolutions.clear(); int freeCells = GameMatrix.TOTAL_FIELDS - riddle.getSetCount(); backtrack(freeCells, new int[2]); return Collections.unmodifiableList(possibleSolutions); } Solver(final GameMatrix solveMe); void setLimit(final int set); List<GameMatrix> solve(); static final int LIMIT; }