Ask Your Question

Revision history [back]

To expand on @dan_fulea's comment, in general, when we have huge amounts of objects, we don't want to store them in a list!

Using iterators is generally preferred: we can run through an iterator, dealing with its element one at a time without storing all of them at once.

In the case at hand, having defined

sage: C = Combinations(range(4096), 3)

we see that, as you correctly recalled,

sage: C.cardinality()
11444858880

and we could define

sage: g3 = (c for c in C if block_matrix(3, 1, [v[c[0]], v[c[1]], v[c[2]]]).rank() >= 4)

and count these combinations with

sage: sum(1 for g in g3)

and then if we had another thing to study about these combinations we could re-define

sage: g3 = (c for c in C if block_matrix(3, 1, [v[c[0]], v[c[1]], v[c[2]]]).rank() >= 4)

and run through them once more.