I am using GSL function to generate permutations, it works fine and result in 4! permutations.
Code:
gsl_permutation * p = gsl_permutation_calloc (4);
gsl_permutation_init (p);
do {gsl_permutation_fprintf (stdout, p, " %u");
printf("\n");
}
while (gsl_permutation_next(p) == GSL_SUCCESS);
return 0;
Output is
Code:
0 1 2 3
1 0 2 3
...... n!
My problem is that i want to reduce the no of permutations on the bases of two parallel arrays.
Code:
int value= {0,1,2,3};
int id = {1,1,3,3};
What i want before generating permutations of "value", it will reduce the no of elements as:
Code:
Psudocode
If id of value element==id of next value element
join that elements like below
newValue= {0_1,2_3}so total no of elements are 2
I will then pass this 2 to generate permutation
result should be 2!
and after permutation if one of the permutation should be {1,0}
it will re-split it into {2,3,0,1}
I don't know how i will do it into C. Need some help plz..Thanks