1import itertools
2def MainProg(items):
3 n = len(items)
4 count = 0
5 if n==0: yield []
6 else:
7 for i in range(len(items)):
8 for cc in MainProg(items[:i]+items[i+3:]):
9 yield [items[i]]+cc
10 count += 1
11for i in MainProg(list("red")): print(''.join(i) + ", ", end="")
12result = MainProg(['t','a','n'])
13next(result)
14print(next(result))
15