# Permutations with Repetition

I am working with a function of type

F[a,b,c,d,e,f]


that obeys the following symmetries:

F[a,b,c,d,e,f]=F[c,d,a,b,e,f]=F[c,d,e,f,a,b],


and

F[a,b,c,d,e,f]=F[b,a,c,d,e,f]=F[a,b,d,c,e,f]=F[a,b,d,c,f,e],


i.e. is symmetric in entries 1-2,3-4 and 5-6 and also is symmetric if I switch any couple of entries with a different one. I want to compute a list with all the possible distinct values of the function, giving different entries. To do this, I want to compute a list of lists containing all the possible distinct orderings of my entries (given the symmetries of my function). From a simple combinatorics argument, I expect

6!/2!2!2!3!=15


different orderings of my entries. To be more specific, the different orderings I need are

{1,2,3,4,5,6},{1,2,3,5,4,6},{1,2,3,6,4,5},{1,3,2,4,5,6},{1,3,2,5,4,6},{1,3,2,6,4,5,},{1,4,2,3,5,6},{1,4,2,5,3,6},{1,4,2,6,3,5},{1,5,2,3,4,6},{1,5,2,4,3,6},{1,5,2,6,3,4},{1,6,2,3,4,5},{1,6,2,4,3,5},{1,6,2,5,3,4}

How can I compute those distinct orderings in Mathematica? Can I exploit some specific features of Permutation[] command?

• Assume a,b,.. are the values you want to feed to f. Then: DeleteDuplicates[f @@@Permutations[{a, b, c, d, e, f}]] gives all the different results. Nov 30, 2021 at 11:40
• @Syed I delete all of them except the first one! All the others possibilities can be obtained by using swapping symmetry within a pair or symmetry in the swapping of pairs. Using combinatorics, among the 6! permutations, only 6!/2!2!2!3! are independent, i.e. cannot be obtained from the others using the mentioned symmetries. Nov 30, 2021 at 12:40
– Syed
Nov 30, 2021 at 12:43
• @Syed I can even list you the different combinations I need: {1,2,3,4,5,6},{1,2,3,5,4,6},{1,2,3,6,4,5},{1,3,2,4,5,6},{1,3,2,5,4,6},{1,3,2,6,4,5,},{1,4,2,3,5,6},{1,4,2,5,3,6},{1,4,2,6,3,5},{1,5,2,3,4,6},{1,5,2,4,3,6},{1,5,2,6,3,4},{1,6,2,3,4,5},{1,6,2,4,3,5},{1,6,2,5,3,4} The problem is that I need similar objects at higher points (i.e. more than six variables), so I was searching for a more algorithmic way of solving the problem Nov 30, 2021 at 12:46

ClearAll[partitionedOrderless]

partitionedOrderless[n_, k_: 2] := Block[{foo},
SetAttributes[foo, Orderless];
DeleteDuplicatesBy[foo @@ foo @@@ Partition[#, k] &] @ Permutations[Range @ n]]


Examples:

partitionedOrderless[6]


partitionedOrderless[4, 2]


partitionedOrderless[6, 3]


partitionedOrderless[8, 2]


partitionedOrderless[8, 4]


etc.