-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathUtils.java
More file actions
60 lines (54 loc) · 1.71 KB
/
Utils.java
File metadata and controls
60 lines (54 loc) · 1.71 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
import java.util.Arrays;
import java.util.Random;
public class Utils {
public static int[][] deepCopy(int[][] original) {
int[][] copy = new int[original.length][original[0].length];
for (int i = 0; i < original.length; i++) {
System.arraycopy(original[i], 0, copy[i], 0, original[i].length);
}
return copy;
}
public static void printMatrix(int[][] data) {
for (int i = 0; i < data.length; i++) {
System.out.println(Arrays.toString(data[i]));
}
}
public static void shuffleArray(char[] inputArray) {
Random rnd = new Random();
for (int i = inputArray.length - 1; i > 0; i--) {
int index = rnd.nextInt(i + 1);
char temp = inputArray[index];
inputArray[index] = inputArray[i];
inputArray[i] = temp;
}
}
public static int characterToID(char character) {
int pentID = -1;
if (character == 'X') {
pentID = 0;
} else if (character == 'I') {
pentID = 1;
} else if (character == 'Z') {
pentID = 2;
} else if (character == 'T') {
pentID = 3;
} else if (character == 'U') {
pentID = 4;
} else if (character == 'V') {
pentID = 5;
} else if (character == 'W') {
pentID = 6;
} else if (character == 'Y') {
pentID = 7;
} else if (character == 'L') {
pentID = 8;
} else if (character == 'P') {
pentID = 9;
} else if (character == 'N') {
pentID = 10;
} else if (character == 'F') {
pentID = 11;
}
return pentID;
}
}