Arrangements and Combinations · Combinations

Lesson 6

Nikolai Chukhin · Alexander S. Kulikov

A combination is simply a subset of a given set. The order of elements in a combination does not matter. Here's how to generate all \(3\)-combinations of a set of size \(5\).

from itertools import combinations


for group in combinations('abcde', 3):
    print(*group)

a b c
a b d
a b e
a c d
a c e
a d e
b c d
b c e
b d e
c d e