java AC code snippet
Послано
esbybb 8 ноя 2015 21:16
there are 24 unique sequences of edges for the specific cube, i use 12 sequences and flip flop front with back for each of them
static int R[][] = new int[][] {
{1,2,3, 4,5, 6},
{5,3,1, 4,2, 6},
{2,1,5, 4,3, 6},
{3,5,2, 4,1, 6},
{6,4,3, 1,5, 2},
{5,3,6, 1,4, 2},
{4,6,5, 1,3, 2},
{3,5,4, 1,6, 2},
{1,2,6, 3,4, 5},
{6,4,2, 3,1, 5},
{2,1,4, 3,6, 5},
{4,6,1, 3,2, 5}
};
static int front_back_rotate[][] = new int[][]{{0,1,2,3,4,5},{0,1,4,5,2,3}};
//left right top front bottom back
//0 1 2 3 4 5
static boolean eqv(int a[], int b[]) {
for (int[] r: R) {
for (int[] I: front_back_rotate) {
int front_back[] = new int[6];
for (int i=0; i<6; i++) {
front_back[r[I[i]]-1] = a[i];
}
if (Arrays.equals(front_back, b)) return true;
}
}
return false;
}