-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestingHarness.java
More file actions
63 lines (46 loc) · 1.24 KB
/
Copy pathTestingHarness.java
File metadata and controls
63 lines (46 loc) · 1.24 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
public class TestingHarness {
public static void main(String[] args) {
ArrayList<Board> boards = null;
try {
boards = inputBoards();
} catch (Exception e) {
e.printStackTrace();
}
List<SudokuSolver> solvers = new ArrayList<SudokuSolver>();
solvers.add(new BasicBacktracking());
solvers.add(new ForwardChecking());
solvers.add(new ArcConsistency());
solvers.add(new AllDiff());
for (SudokuSolver s : solvers) {
for (Board b : boards) {
s.solveSudoku(b);
}
System.out.println("----------------");
}
}
public static ArrayList<Board> inputBoards() throws IOException {
ArrayList<Board> ans = new ArrayList<Board>();
FileReader in = new FileReader("testcases.txt");
BufferedReader br = new BufferedReader(in);
for (int r = 0; r < 10; r++) {
byte[][] b = new byte[9][9];
// Consume the text
br.readLine();
for (int i = 0; i < 9; i++) {
char[] line = br.readLine().toCharArray();
for (int j = 0; j < 9; j++) {
b[i][j] = (byte) (line[j] - '0');
}
}
Board board = new Board(b);
ans.add(board);
}
br.close();
return ans;
}
}