IIUC, you are trying to do the following -
- Create color, shape combinations with some lower and upper limit for each (color = 3, shape = 5), (color = 1, shape = 99) etc.
- Then you are trying to permute over these color combinations for each permutation order from 1 to m (in your example m = 5)
Here is a piece of code that should get you something similar. Please do note, this will explode exponentially, so avoid larger limits.
import itertools
color_i = 1
color_n = 5
shape_i = 1
shape_n = 6
permutes = 3
# color, shape combos
combos = list(itertools.product(range(color_i, color_n+1), range(shape_i, shape_n+1)))
# create permutations from the color, shape combos
permutations = []
for p in range(permutes):
for i in itertools.permutations(combos,r=p+1):
permutations.append(list(zip(*i)))
permutations
[[(1,), (1,)],
[(1,), (2,)],
[(1,), (3,)],
[(1,), (4,)],
[(1,), (5,)],
[(1,), (6,)],
[(2,), (1,)],
[(2,), (2,)],
[(2,), (3,)],
[(2,), (4,)],
[(2,), (5,)],
[(2,), (6,)],
[(3,), (1,)],
[(3,), (2,)],
[(3,), (3,)],
[(3,), (4,)],
[(3,), (5,)],
[(3,), (6,)],
[(4,), (1,)],
[(4,), (2,)],
[(4,), (3,)],
[(4,), (4,)],
[(4,), (5,)],
[(4,), (6,)],
[(5,), (1,)],
[(5,), (2,)],
[(5,), (3,)],
[(5,), (4,)],
[(5,), (5,)],
[(5,), (6,)],
[(1, 1), (1, 2)],
[(1, 1), (1, 3)],
...,
[(1, 4), (1, 2)],
[(1, 4), (1, 3)],
[(1, 4), (1, 4)],
[(1, 4), (1, 5)],
[(1, 4), (1, 6)],
[(1, 5), (1, 1)],
[(1, 5), (1, 2)],
[(1, 5), (1, 3)],
[(1, 5), (1, 4)],
[(1, 5), (1, 5)],
[(1, 5), (1, 6)],
[(1, 1), (2, 1)],
[(1, 1), (2, 3)],
[(1, 1), (2, 4)],
[(1, 1), (2, 5)],
[(1, 1), (2, 6)],
[(1, 2), (2, 1)],
[(1, 2), (2, 2)],
...,
[(4, 4), (3, 6)],
[(4, 5), (3, 1)],
[(4, 5), (3, 2)],
[(4, 5), (3, 3)],
[(4, 5), (3, 4)],
[(4, 5), (3, 5)],
[(4, 5), (3, 6)],
[(4, 1), (4, 1)],
[(4, 1), (4, 2)],
[(4, 1), (4, 3)],
[(4, 1), (4, 4)],
[(4, 1), (4, 5)],
...,
[(5, 5), (6, 2)],
[(5, 5), (6, 3)],
[(5, 5), (6, 4)],
[(5, 5), (6, 5)],
[(1, 1, 1), (1, 2, 3)],
[(1, 1, 1), (1, 2, 4)],
[(1, 1, 1), (1, 2, 5)],
[(1, 1, 1), (1, 2, 6)],
[(1, 1, 2), (1, 2, 1)],
[(1, 1, 2), (1, 2, 2)],
[(1, 1, 2), (1, 2, 3)],
...,
[(1, 1, 4), (1, 2, 6)],
[(1, 1, 5), (1, 2, 1)],
[(1, 1, 5), (1, 2, 2)],
[(1, 1, 5), (1, 2, 3)],
[(1, 1, 5), (1, 2, 4)],
[(1, 1, 5), (1, 2, 5)],
[(1, 1, 5), (1, 2, 6)],
[(1, 1, 1), (1, 3, 2)],
[(1, 1, 1), (1, 3, 4)],
[(1, 1, 1), (1, 3, 5)],
[(1, 1, 1), (1, 3, 6)],
[(1, 1, 2), (1, 3, 1)],
[(1, 1, 2), (1, 3, 2)],
[(1, 1, 2), (1, 3, 3)],
[(1, 1, 2), (1, 3, 4)],
[(1, 1, 2), (1, 3, 5)],
[(1, 1, 2), (1, 3, 6)],
[(1, 1, 3), (1, 3, 1)],
[(1, 1, 3), (1, 3, 2)],
[(1, 1, 3), (1, 3, 3)],
[(1, 1, 3), (1, 3, 4)],
[(1, 1, 3), (1, 3, 5)],
[(1, 1, 3), (1, 3, 6)],
[(1, 1, 4), (1, 3, 1)],
[(1, 1, 4), (1, 3, 2)],
[(1, 1, 4), (1, 3, 3)],
[(1, 1, 4), (1, 3, 4)],
[(1, 1, 4), (1, 3, 5)],
[(1, 1, 4), (1, 3, 6)],
[(1, 1, 5), (1, 3, 1)],
[(1, 1, 5), (1, 3, 2)],
[(1, 1, 5), (1, 3, 3)],
[(1, 1, 5), (1, 3, 4)],
[(1, 1, 5), (1, 3, 5)],
[(1, 1, 5), (1, 3, 6)],
[(1, 1, 1), (1, 4, 2)],
[(1, 1, 1), (1, 4, 3)],
[(1, 1, 1), (1, 4, 5)],
[(1, 1, 1), (1, 4, 6)],
[(1, 1, 2), (1, 4, 1)],
[(1, 1, 2), (1, 4, 2)],
[(1, 1, 2), (1, 4, 3)],
[(1, 1, 2), (1, 4, 4)],
[(1, 1, 2), (1, 4, 5)],
[(1, 1, 2), (1, 4, 6)],
[(1, 1, 3), (1, 4, 1)],
[(1, 1, 3), (1, 4, 2)],
[(1, 1, 3), (1, 4, 3)],
[(1, 1, 3), (1, 4, 4)],
[(1, 1, 3), (1, 4, 5)],
[(1, 1, 3), (1, 4, 6)],
...]
How it works -
Create itertools.product
using ranges for color and shape. This gives you all possible (color, shape) tuples.
For permutation order 1 to m (1, 2, 3, ..., m) permute over this list of all possible tuples k times where 1>=k>=m
Use list(zip(*i))
on each generated permutation to transpose it from [(color1, shape1), (color2, shape2), (color3, shape3)]
to [(color1, color2, color3), (shape1, shape2, shape3)]