/************ * playing with permutations: * * Given 6 corners of 2 adjacent sides of * a Rubik's Cube, how can they be permuted * by just the two F,R moves? * * 0 - 3 - 4 * | f | r | * 1 - 2 - 5 * * I = [0,1,2,3,4,5] * * F = [1,2,3,0,4,5] * R = [0,1,5,2,3,4] * * F' = [3,0,1,2,4,5] * R' = [0,1,3,4,5,2] * * RESULT : (see perm.out) * Can only get 1/6'th of the 720 positions = 120 * Furthest is a unique one at 7 moves out = [ 1 0 3 2 5 4 ] * which has top and bottom swapped. * * I don't have a good intution for why... * * Jim Mahoney 3/16/00 *************/ #include "Utilities.h" #include #define MAX_DEPTH 11 #define N_digits 6 #define N_fact 720 void print_disjoint(int arr[], int N){ int i, index, t, target; int inner, outer, next_target; int ar[N_digits]; for (i=0;i= N) { outer=0; // we're done next_target = 0; } else { for (i=0;idepth) { seen[j_perm]=depth; } if (seen[j_perm]==-1) { seen[j_perm]=depth; } //// printf(" perm = %i, seen[perm] = %i \n", j_perm, seen[j_perm]); // descend the tree if (depth < (MAX_DEPTH-1)) { descend_tree(depth+1, 0, iT, seen); descend_tree(depth+1, 1, iT, seen); descend_tree(depth+1, 2, iT, seen); descend_tree(depth+1, 3, iT, seen); } } // Let's see if the permutation routines in Utilitiy still work. void main(){ int arr[N_digits]; // array to be permuted int arb[N_digits]; // another array int i,j,total; long x; int analysis[MAX_DEPTH]; // this needs to be // I'm using N=6 here; 6! = 720 int seen[N_fact]; // array of which permutations have been seen // after a certain number of moves // mark all permutations unseen so far. for (i=0;iN_fact) // this shouldn't happen break; } printf(" , depth=%i, cycle=%i, ", seen[i], j); print_disjoint(arr, N_digits); printf("\n"); } } printf(" ---- \n"); // analysis: count how many new positions seen at each level, // and how many reached total. for (i=0;i