Is there any way to form combinations in parts ?
What I want to say will be clear from this.
Suppose I run this code:
T = Tuples((0,1),4)
comb= Combinations(T,5)
show(comb.cardinality())
The output is
4368
My concern is this that I have to use these combinations further in my code. The problem is that for 4-tuples of (0,1) the processing is instant(because only 4368 combinations), but for 300-tuples of (0,1) even after many hours it is still processing. So, I was thinking that is it possible to form combinations in parts in different codes and run these codes separately so that output is faster.
What I mean to say is that, in the above code for example, is it possible that only first, say 10% (that is 437) of the combinations are formed. Then in another code the next 10%(that is 438th to 974th) combinations are formed and so on. Or is there any other way to make this faster
If you don't do
comb.cardinality()
, the rest should basically be instant:Combinations(T, 300)
produces an iterator (as in Sébastien's answer), and if you do something likefor x in comb...
, it will produce the entries one at a time.Okay. Thanks