-
Notifications
You must be signed in to change notification settings - Fork 0
/
KnightBoardTest.java
38 lines (33 loc) · 1009 Bytes
/
KnightBoardTest.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
38
public class KnightBoardTest {
public static void main(String[] args) {
for (int i = 5; i < 100; i++) {
KnightBoard k = new KnightBoard(i, i);
k.solve(0, 0);
System.out.println(i);
System.out.println(k);
}
}
//testcase must be a valid index of your input/output array
public static void runTest(int i){
KnightBoard b;
int[]m = {4,5,5,5,5};
int[]n = {4,5,4,5,5};
int[]startx = {0,0,0,1,2};
int[]starty = {0,0,0,1,2};
int[]answers = {0,304,32,56,64};
if(i >= 0 ){
try{
int correct = answers[i];
b = new KnightBoard(m[i%m.length],n[i%m.length]);
int ans = b.countSolutions(startx[i],starty[i]);
if(correct==ans){
System.out.println("PASS board size: "+m[i%m.length]+"x"+n[i%m.length]+" "+ans);
}else{
System.out.println("FAIL board size: "+m[i%m.length]+"x"+n[i%m.length]+" "+ans+" vs "+correct);
}
}catch(Exception e){
System.out.println("FAIL Exception case: "+i);
}
}
}
}