-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
46 lines (35 loc) · 1.36 KB
/
Main.java
File metadata and controls
46 lines (35 loc) · 1.36 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
import java.io.BufferedReader;
import java.io.FileReader;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Solver solver = new Solver();
Scanner scanner = new Scanner(System.in);
System.out.print("Enter test batch to run: ");
String testBatch = scanner.nextLine();
scanner.close();
try {
BufferedReader br = new BufferedReader(new FileReader("test/" + testBatch));
String line;
System.out.println("Running test batch " + testBatch + "...");
while ((line = br.readLine()) != null) {
String[] split = line.split(" ");
String seq = split[0];
int expectedScore = Integer.parseInt(split[1]);
Position P = new Position();
P.play(seq);
int score = solver.solve(P);
if (score != expectedScore) {
System.out.println("Error: " + seq + " " + score + " " + expectedScore);
br.close();
return;
}
System.out.println(seq + " " + score);
}
br.close();
System.out.println("Test batch " + testBatch + " passed!");
} catch (Exception e) {
System.out.println(e);
}
}
}