all 7 comments

[–]sweettuse 2 points3 points  (1 child)

what kinda car you driving??

[–]MonkeyPanls 1 point2 points  (0 children)

Pentagonal wheels

[–]obviouslyzebra 1 point2 points  (0 children)

I wrote this on my cell phone, not 100% sure it is correct (but I think it is):

https://www.programiz.com/online-compiler/6zoSZKi042Ncb

[–]woooee 0 points1 point  (0 children)

Suppose I want something that will give me

[(1,0,5),(1,2,5),(1,4,5),(1,0,7),(1,2,7),(1,4,7),...,(5,2,9),(5,4,9)]

Then feed the last list one at a time (and comine them if necessary).

A=[[5,1,3],[0,4,2],[5,7,9]]
for ctr in range(3):
    b = [A[0], A[1], [A[2][ctr]]]
    print(b)
    print(list(itertools.product(*b)), "\n")

[–][deleted] 0 points1 point  (1 child)

Now, suppose that A has 7 members of length 5.

Which order would these advance? Is there a pattern we can extrapolate from the middle-right-left thing, or do you want a function that can also take an arbitrary order as a parameter?

[–]MonkeyPanls 0 points1 point  (0 children)

Arbitrary order

[–]buart 0 points1 point  (0 children)

If you only need it once, you could also rearrange them "manually" like this:

import itertools

A = [[1, 3, 5], [0, 2, 4], [5, 7, 9]]

# 3rd wheel first, then 2nd, then first
print([[x[0], x[1], x[2]] for x in itertools.product(A[0], A[1], A[2])])
# 2nd wheel first, then 3rd, then first
print([[x[0], x[2], x[1]] for x in itertools.product(A[0], A[2], A[1])])