I am working with a function of type


that obeys the following symmetries:




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


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


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

  • $\begingroup$ 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. $\endgroup$ Nov 30, 2021 at 11:40
  • $\begingroup$ @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. $\endgroup$
    – McSenegal
    Nov 30, 2021 at 12:40
  • $\begingroup$ Please add the required combinations to your post. $\endgroup$
    – Syed
    Nov 30, 2021 at 12:43
  • $\begingroup$ @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 $\endgroup$
    – McSenegal
    Nov 30, 2021 at 12:46

1 Answer 1


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



enter image description here

partitionedOrderless[4, 2]

enter image description here

partitionedOrderless[6, 3] 

enter image description here

partitionedOrderless[8, 2] 

enter image description here

partitionedOrderless[8, 4] 

enter image description here



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.