5
$\begingroup$

I want to start with:

{a,b},{c,d},{e,f}

and end up with:

{a,c,e},{a,c,f},{a,d,e},{a,d,f},{b,c,e},{b,c,f},{b,d,e},{b,d,f}

then do every ordering of each:

{a,c,e},{a,e,c},{c,a,e},{c,e,a},{e,a,c},{e,c,a},{a,c,f},{a,f,c},etc.

I believe Tuples combined with Permutations maybe are the way to go, but unsure how to do this.

$\endgroup$
1
  • 1
    $\begingroup$ Not as elegant as your own solution, but also Outer[Permutations[{##}]&, Sequence@@set]//Catenate//Catenate $\endgroup$
    – user1066
    Commented Jun 2, 2021 at 11:04

2 Answers 2

9
$\begingroup$

Figured it out. Was easier than I thought:

set={{a,b},{c,d},{e,f}};
set2=Map[Permutations,Tuples[set]]

{{{a,c,e},{a,e,c},{c,a,e},{c,e,a},{e,a,c},{e,c,a}},
{{a,c,f},{a,f,c},{c,a,f},{c,f,a},{f,a,c},{f,c,a}},
{{a,d,e},{a,e,d},{d,a,e},{d,e,a},{e,a,d},{e,d,a}},
{{a,d,f},{a,f,d},{d,a,f},{d,f,a},{f,a,d},{f,d,a}},
{{b,c,e},{b,e,c},{c,b,e},{c,e,b},{e,b,c},{e,c,b}},
{{b,c,f},{b,f,c},{c,b,f},{c,f,b},{f,b,c},{f,c,b}},
{{b,d,e},{b,e,d},{d,b,e},{d,e,b},{e,b,d},{e,d,b}},
{{b,d,f},{b,f,d},{d,b,f},{d,f,b},{f,b,d},{f,d,b}}}
$\endgroup$
8
$\begingroup$

1. GroupOrbits:

set3 = GroupOrbits[SymmetricGroup @ 3, Tuples @ set, Permute];

2. Distribute:

set4 = Distribute[set, List, List, List, Permutations @* List];

Both give the same output as OP's set2:

set3 == set4 == set2
True
$\endgroup$

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.