Generating a random permuttion of the values from 0..N-1 is particularly easy. Assuming that you have a good source of 'random numbers', then you can simply: unsigned char a[N]; for ( i=n-1; i >0; --i ) { j = random value in range 0..i temp = a[j]; a[j] = a[i]; a[i] = temp; } And creating the reversed table is also very simple: unsigned char b[N]; for (i=0; i < N; ++i) { b[ a[i] ] = i; } Bob Ammerman RAm Systems -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist