Arrangements and Combinations · Arrangements and Combinations

Lesson 2

Nikolai Chukhin · Alexander S. Kulikov

In the summary list below, \(k=2\) objects are selected from \(n=3\) options \(\Sigma=\{{\tt a},{\tt b},{\tt c}\}\). In combinatorics, the urn scheme is also used to describe all four types of objects: there is an urn containing \(n=3\) balls \(\Sigma=\{{\tt a},{\tt b},{\tt c}\}\), and we sequentially draw \(k=2\) balls from it; we may or may not return the ball to the urn, and the order of the drawn balls may or may not matter.

  • Arrangements with repetition.  Order matters, elements can repeat. Also known as: a word (or an element of) \(\Sigma^{k}\).
    from itertools import product
    
    for p in product('abc', repeat=2):
        print(*p, sep='', end=' ')

    aa ab ac ba bb bc ca cb cc
    

  • Arrangements without repetition.  Order matters, elements cannot repeat. Also known as: \(k\)-permutation.
    from itertools import permutations
    
    for p in permutations('abc', 2):
        print(*p, sep='', end=' ')

    ab ac ba bc ca cb
    

  • Combinations with repetition.  Order does not matter, elements can repeat. Also known as: \(k\)-multiset.
    from itertools import combinations_with_replacement
    
    for p in combinations_with_replacement('abc', 2):
        print(*p, sep='', end=' ')

    aa ab ac bb bc cc
    

  • Combinations without repetition.  Order does not matter, elements cannot repeat. Also known as: \(k\)-set.
    from itertools import combinations
    
    for p in combinations('abc', 2):
        print(*p, sep='', end=' ')

    ab ac bc