def all_subsets(n, card):
    if card == 0:
        yield 0
    else:
        for i in range(card - 1, n):
            for e in all_subsets(i, card - 1):
                yield e | (1 << i)
generates all sets from {0, ..., n - 1} of cardinality card
dataset/ETHPy150Open jilljenn/tryalgo/tryalgo/arithm_expr_target.py/all_subsets