Compare commits
No commits in common. "master" and "dogge" have entirely different histories.
2 changed files with 6 additions and 23 deletions
|
@ -20,18 +20,10 @@ public class Solver implements SudokuSolver {
|
||||||
this.board = board;
|
this.board = board;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** {@inheritDoc} */
|
||||||
* {@inheritDoc}
|
|
||||||
* <p>
|
|
||||||
* Note that this returns a copy of the board, not the actual board
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public int[][] getBoard() {
|
public int[][] getBoard() {
|
||||||
int[][] copy = new int[9][9];
|
return board;
|
||||||
for (int row = 0; row < 9; row++) {
|
|
||||||
System.arraycopy(board[row], 0, copy[row], 0, 9);
|
|
||||||
}
|
|
||||||
return copy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Resets the board to all zeros */
|
/** Resets the board to all zeros */
|
||||||
|
@ -42,6 +34,7 @@ public class Solver implements SudokuSolver {
|
||||||
row[i] = 0;
|
row[i] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// board = new int[9][9];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* {@inheritDoc} */
|
/* {@inheritDoc} */
|
||||||
|
|
|
@ -17,13 +17,9 @@ class SolverTest {
|
||||||
Solver solver = new Solver();
|
Solver solver = new Solver();
|
||||||
int[][] board = new int[9][9];
|
int[][] board = new int[9][9];
|
||||||
solver.setBoard(board);
|
solver.setBoard(board);
|
||||||
|
assertEquals(board, solver.getBoard());
|
||||||
for (int row = 0; row < 9; row++) {
|
|
||||||
assertArrayEquals(board[row], solver.getBoard()[row]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void randomizeBoardTest() {
|
void randomizeBoardTest() {
|
||||||
int[][] board = new int[9][9];
|
int[][] board = new int[9][9];
|
||||||
|
@ -32,12 +28,6 @@ class SolverTest {
|
||||||
assertNotEquals(board, solver.getBoard());
|
assertNotEquals(board, solver.getBoard());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
void emptyTest() {
|
|
||||||
Solver solver = new Solver();
|
|
||||||
assertTrue(solver.solve());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void legalTest() {
|
void legalTest() {
|
||||||
Solver solver = new Solver();
|
Solver solver = new Solver();
|
||||||
|
|
Loading…
Reference in a new issue