-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSudokuSolver.java
37 lines (32 loc) · 1.14 KB
/
SudokuSolver.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
public class SudokuSolver {
private int numRows, numCols;
private Board sudokuBoard;
public SudokuSolver(String fileName) {
File f = new File(fileName);
try (Scanner reader = new Scanner(f)) {
String dimension = reader.nextLine();
numRows = Integer.parseInt(dimension.substring(0, dimension.indexOf('x')));
numCols = Integer.parseInt(dimension.substring(dimension.indexOf('x') + 1));
String boardString = "";
while (reader.hasNext()) {
boardString += reader.nextLine() + " ";
}
reader.close();
sudokuBoard = new Board(numRows, numCols, boardString);
} catch (FileNotFoundException e) {
System.out.println("FILE NOT FOUND!");
}
}
public Board board() {
return sudokuBoard;
}
public void solveBoard() {
System.out.println(sudokuBoard);
sudokuBoard.fullProp();
sudokuBoard.solve();
System.out.println(sudokuBoard);
}
}