Hi I have this function that will exclude the redundant permutations. If processes are adjacent and belongs to same group it will exclude this permutation order. I need to change it like it will check all the processes that belongs to same group and skip all these combination weather they are adjacent or not but belongs to the same group For example : Let we have 4 processes. Total No of permutations are 4!=24

<b> 0 1 2 3 (here 0,1,3 belongs to same group) </b>

This function will exclude the permutation that interchange 0 with 1 and i want to modify it like it will exclude all the permutations order that have same group weather they are adjacent or not like it may exclude 0 with 3 permutation order too . Function is

If the number of elements is small (e.g. 4 in your example), then you might generate all permutations and use a hash to remove those that are duplicates elements of the same group at the same place). This may look like brute force approach, but if you can do it in a couple of code lines, rather than a few dozens, it might be the best approach.

I am still not clear about your requirements, but it is very likely that there is a module that does what you want. I suggest that you consider CPAN modules that have the word "combinatorics" in their names. Even if you do not find a useful module, the search will probably help you in the use of standard terminology. Good Luck, Bill