bool moveIntoPlace(Cube &cube, vector<int> values, int x, int y, int z) { for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { for (int k = 0; k < 3; k++) { if ((i == 1 && j == 1 && k == 1) || (i == x && j == y && k == z)) { continue; } if ((values.size() == 2 && ((i + j + k) % 2 == 1)) || (values.size() == 3 && (i%2 == 0 && j%2 == 0 && k%2 == 0))) { vector<int> compare; for (int l = 0; l < 6; l++) { int colour = cube.getColour(i,j,k,l); if (colour != -1) { compare.push_back(colour); } } assert(compare.size() == values.size()); sort(compare.begin(), compare.end()); if (compare == values) { // cout << "Swapping " << x << " " << y << " " << z << " with " << i << " " << j << " " << k << endl; cube.swap(i,j,k,x,y,z); return true; } } } } } return false; }