It is somewhat annoying that len
and next
don't do what you think with combinatorial classes. Is there any more Pythonic (e.g. list comprehension) way to do the following?
prof = [1,3,2,0,0,3]
L = []
P = Permutations(3)
Q = P.__iter__()
for j in range(P.cardinality()):
tp = Q.next()
for i in range(prof[j]):
L.append(tp)
Part of the issue is that I would really rather not use Q
, since it is "used up" when I'm done. I really want something that is succinct, but I just could not find a way to do it.