Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Use the built-in Python command itertools.combinations:

sage: import itertools
sage: L = [1..5]; L
[1, 2, 3, 4, 5]
sage: for s in itertools.combinations(L, 3):
....:     print s
....:     
(1, 2, 3)
(1, 2, 4)
(1, 2, 5)
(1, 3, 4)
(1, 3, 5)
(1, 4, 5)
(2, 3, 4)
(2, 3, 5)
(2, 4, 5)
(3, 4, 5)