Counting of combinations

61 views
Skip to first unread message

Peter Luschny

unread,
Jan 4, 2024, 3:05:51 PMJan 4
to sage-support
Hi all,

please consider this counting of special combinations:

    def C(n, k):
        return Compositions(n, max_part=k, inner=[k]).cardinality()
    for n in (0..4): print([C(n, k) for k in (0..n)])

    [0]
    [0, 1]
    [0, 1, 1]
    [0, 1, 1, 1]
    [0, 1, 2, 1, 1]

Edge cases are notoriously difficult and error-prone. Maybe a
combinatorialist can help me: I suspect the case C(0, 0) to be
wrong, it shouldn't be C(0,0) = 0, but C(0,0) = 1.

The counted situation looks like this to me:

[[0]]
[[ ], [[1]]]
[[ ], [[1, 1]],       [[2]]]
[[ ], [[1, 1, 1]],    [[2, 1]],             [[3]]]
[[ ], [[1, 1, 1, 1]], [[2, 2],  [2, 1, 1]], [[3, 1]], [[4]]]

Peter
P.S. Sage 10.1


Reply all
Reply to author
Forward
0 new messages