Given a list of 3-tuples, for example:[(1,2,3), (4,5,6), (7,8,9)]
how would you compute all possible combinations and combinations of subsets?
In this case the result should look like this:
[
(1), (1,4), (1,5), (1,6), (1,7), (1,8), (1,9), (1,4,7), (1,4,8), (1,4,9), (1,5,7), (1,5,8), (1,5,9), (1,6,7), (1,6,8), (1,6,9),
(2), ...,
(3), ...,
(4), (4,7), (4,8), (4,9),
(5), (5,7), (5,8), (5,9),
(6), (6,7), (6,8), (6,9),
(7), (8), (9)
]
- all tuples with identical elements are regarded the same
- combinations which derive from the same tuples are not allowed (e.g. these shouldn't be in the solution:
(1,2)
,(4,6)
or(7,8,9)
)
(1)
to(9)
are part of the soultion if(1,2)
is not allowed given the second rule ? – Gendarmerie[(x,) for x in the_list[0]]
, 2)[(x,y) for x in the_list[0] for y in the_list[1]]
, and 3)[(x,y,z) for x in the_list[0] for y in the_list[1] for z in the_list[2]]
. – Yockey