import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringBuffer sb = new StringBuffer("");
int avaibleIt[][] = {{0, 1, 2, 3, 4, 5}, {1, 5, 2, 3, 0, 4}, {2, 1, 5, 0, 4, 3}, {3, 1, 0, 5, 4, 2},
{4, 0, 2, 3, 5, 1}, {5, 4, 2, 3, 1, 0}};
String m = "";
while ((m = br.readLine()) != null) {
char[] x = new char[6], y = new char[6];
for (int i = 0; i < 6; i++) {
x[i] = m.charAt(i);
}
for (int i = 0; i < 6; i++) {
y[i] = m.charAt(i + 6);
}
sb.append((cubeRotation(avaibleIt, x, y) + "").toUpperCase()).append("\n");
}
System.out.print(sb);
}
static boolean cubeRotation(int[][] arr, char[] x, char[] y) {
char[] temp = new char[6];
for (int i = 0; i < 6; i++) {
for (int j = 0; j < 6; j++) {
temp[j] = x[arr[i][j]];
}
for (int j = 0; j < 4; j++) {
char tempChar;
tempChar = temp[1];
temp[1] = temp[2];
temp[2] = temp[4];
temp[4] = temp[3];
temp[3] = tempChar;
if (compareChars(temp, y)) {
return true;
}
}
}
return false;
}
static boolean compareChars(char[] x, char[] y) {
for (int i = 0; i < x.length; i++) {
if (x[i] != y[i]) {
return false;
}
}
return true;
}
}
No comments:
Post a Comment