I am having some problem with permutations! I am a really big noob when it comes to python so any help would be appreciated!
Lets say I have a list that ranges from 1-6
from itertools import product
LIMIT = 4
l1 = [1,2,3]
results = []
for i in range(1, LIMIT+1):
results.extend(product(l1, repeat=i))
print(results)
will yield:
[(1,), (2,), (3,),
(1, 1), (1, 2), (1, 3),
(2, 1), (2, 2), (2, 3),
(3, 1), (3, 2), (3, 3),
(1, 1, 1), (1, 1, 2), (1, 1, 3),
(1, 2, 1), (1, 2, 2), (1, 2, 3),
(1, 3, 1), (1, 3, 2), (1, 3, 3),
(2, 1, 1), (2, 1, 2), (2, 1, 3),
(2, 2, 1), (2, 2, 2), (2, 2, 3),
(2, 3, 1), (2, 3, 2), (2, 3, 3),
(3, 1, 1), (3, 1, 2), (3, 1, 3),
(3, 2, 1), (3, 2, 2), (3, 2, 3),
(3, 3, 1), (3, 3, 2), (3, 3, 3),
(1, 1, 1, 1), (1, 1, 1, 2), (1, 1, 1, 3),
(1, 1, 2, 1), (1, 1, 2, 2), (1, 1, 2, 3),
(1, 1, 3, 1), (1, 1, 3, 2), (1, 1, 3, 3),
(1, 2, 1, 1), (1, 2, 1, 2), (1, 2, 1, 3),
(1, 2, 2, 1), (1, 2, 2, 2), (1, 2, 2, 3),
(1, 2, 3, 1), (1, 2, 3, 2), (1, 2, 3, 3),
(1, 3, 1, 1), (1, 3, 1, 2), (1, 3, 1, 3),
(1, 3, 2, 1), (1, 3, 2, 2), (1, 3, 2, 3),
(1, 3, 3, 1), (1, 3, 3, 2), (1, 3, 3, 3),
(2, 1, 1, 1), (2, 1, 1, 2), (2, 1, 1, 3),
(2, 1, 2, 1), (2, 1, 2, 2), (2, 1, 2, 3),
(2, 1, 3, 1), (2, 1, 3, 2), (2, 1, 3, 3),
(2, 2, 1, 1), (2, 2, 1, 2), (2, 2, 1, 3),
(2, 2, 2, 1), (2, 2, 2, 2), (2, 2, 2, 3),
(2, 2, 3, 1), (2, 2, 3, 2), (2, 2, 3, 3),
(2, 3, 1, 1), (2, 3, 1, 2), (2, 3, 1, 3),
(2, 3, 2, 1), (2, 3, 2, 2), (2, 3, 2, 3),
(2, 3, 3, 1), (2, 3, 3, 2), (2, 3, 3, 3),
(3, 1, 1, 1), (3, 1, 1, 2), (3, 1, 1, 3),
(3, 1, 2, 1), (3, 1, 2, 2), (3, 1, 2, 3),
(3, 1, 3, 1), (3, 1, 3, 2), (3, 1, 3, 3),
(3, 2, 1, 1), (3, 2, 1, 2), (3, 2, 1, 3),
(3, 2, 2, 1), (3, 2, 2, 2), (3, 2, 2, 3),
(3, 2, 3, 1), (3, 2, 3, 2), (3, 2, 3, 3),
(3, 3, 1, 1), (3, 3, 1, 2), (3, 3, 1, 3),
(3, 3, 2, 1), (3, 3, 2, 2), (3, 3, 2, 3),
(3, 3, 3, 1), (3, 3, 3, 2), (3, 3, 3, 3)]