So, I started off with this array:
array = ['A', 'B', 'C', 'D', 'E', 'F']
And I played around for a little while before getting python to print each unique, non-repeating combination, like so:
AB,
AC,
AD,
AE,
AF,
BC,
BD,
BE,
BF,
CD,
CE,
CF,
DE,
DF,
EF,
But now, I'd like to take all of these into a new array:
array2 = ['AB', 'AC', 'AD'...., 'EF']
And print all 3-element-long combinations, not including rearrangements, that have no repeats.
What I mean by 'no repeats':
AB
, CD
and EF
is a 3-element long combination with no repeats, but AB
, BD
and EF
is a 3-element-long combination with repeats, as 'B'
appears in both 'AB' and 'BD'
.
What I mean by 'not including rearrangements':
AB, CD, EF would be the same as BA, DC, FE, because all of the 2-letter elements are the same (BA is AB rearranged, DC is CD rearranged, and FE is EF rearranged). So ideally it'd print something like:
AB CD EF,
AB CE DF,
AB CF DE,
AC BD EF,
AC BE DF,
AC BF DE,
AD BC EF,
AD BE CF,
AD BF CE,
AE BC DF,
AE BD CF,
AE BF CD,
AF BC DE,
AF BD CE,
AF BE CD,
I believe those are all the combinations where no 2-letter element is repeated.
How would I go about printing this? Thanks!