# I want to find a combination using itertools in a three-dimensional array.

Asked 2 months ago, Updated 2 months ago, 1 views

I'm thinking of finding a combination using itertools in a three-dimensional array.
I would like to find the total combination of li1[i] to choose one by one.

`````` li1 = [[0,2], [0,1,2]],
[[3]],
[[7, 9], [7,8,9],[7,6,9]],
[[11]],
[[12, 10, 20], [12, 14, 18, 20]]]
``````

For example, if you combine the beginnings of li1[i], li1[0]→li1[1][0]→li1[2][0]→li1[3][0]li1[4][0] to [0,2,3,7,9,11,12,10,20].

``````result=[0, 2, 3, 7, 9, 11, 12, 10, 20], [0, 2, 3, 7, 9, 11, 14, 18, 20],
[0,2,3,7, 8, 9,11,12,10,20],[0,2,3,7, 8, 9,11,12,14,18,20],
[0,2,3,7,6,9,11,12,10,20],[0,2,3,7,6,9,11,12,14,18,20],
[0,1,2,3,7,9,11,12,10,20],[0,1,2,3,7,9,11,12,14,18,20],
[0,1,2,3,7,8,9,11,12,10,20],[0,1,2,3,7,8,9,11,12,14,18,20],
[0,1,2,3,7,6,9,11,12,10,20],[0,1,2,3,7,6,9,11,12,14,18,20]]
``````

It doesn't matter if you don't use itertools.Thank you for your cooperation.

python

2022-09-30 13:48

``````>>import intertools
>> [sum(list(l), []) for lin apply (itertools.product, li1)]
``````

2022-09-30 13:48

## If you have any answers or tips

Popular Tags
python x 4433
android x 1590
java x 1475
javascript x 1383
c x 903
c++ x 831
ruby-on-rails x 681
php x 678
python3 x 651
html x 631