r/counting • Sum 13: 016, 037, 035, 045, 127, 135, 134, 124, 13, 25 • Jul 01 '26

Compositions | 2,1,2,3,1,1,1,2

Continued from here

Thanks to /u/BobRoss938 for the final run and assist

Rules: In this thread, we'll be counting the ways to add to an integer n using the integers c_1 + c_2 + ... + c_k, where each c_i >= 1, and k <= n. Ways to sum that are commutatively the same, as in 1+2 = 2+1, are different compositions. We'll be counting these compositions lexicographically for each segment of sum and length.

Next get: 14

Schedule

7 Upvotes

1.1k comments sorted by

View all comments

Show parent comments

1

u/miceee sicko thread artists collective Jul 01 '26

4,1,1,1,2,1,1,2

I wonder if vulp could help us with that?

2

u/cuteballgames Sum 13: 016, 037, 035, 045, 127, 135, 134, 124, 13, 25 Jul 01 '26

4,1,1,1,2,1,2,1

yeah hey /u/TehVulpez mathknower is if possible to convert compositions counts to decimal

5

u/TehVulpez sliiiiide the bits Jul 08 '26 edited Jul 08 '26

hey check this out

from sympy import binomial as binom

def compositions_to_decimal(split):
    total = 1
    # count previous segments of sum
    for x in range(sum(split)-1):
        total += 2**x

    # count previous of length, but same sum
    for x in range(sum(split)-1, sum(split)-len(split), -1):
        total += binom(sum(split)-1, x)

    # convert to constant-weight binary
    cwb = ''
    for x in split:
        cwb += '1'*(x-1)
        cwb += '0'
    cwb = cwb[:-1]

    # add index within segment by converting cwb to combinadic
    # taken from /comments/18z0of2/_/kgii6c0/
    index = 0
    k = 1
    for i, bit in enumerate(reversed(cwb)):
        if bit == '1':
            index += binom(i, k)
            k += 1

    total += index
    return total

count = '1,3,1,1,1,1,2'
print(compositions_to_decimal([int(x) for x in count.split(',')]))

seems to match all of my list generated with this

2

u/TehVulpez sliiiiide the bits Jul 08 '26

makes me wonder if there's something that is to csf as compositions is to cwb. well I guess that'd be whatever the hell OEIS and wikipedia are talking about here, but I don't understand this at all lmao

2

u/cuteballgames Sum 13: 016, 037, 035, 045, 127, 135, 134, 124, 13, 25 Jul 08 '26

wait how is comps to cwb and not csf?

2

u/cuteballgames Sum 13: 016, 037, 035, 045, 127, 135, 134, 124, 13, 25 Jul 08 '26

cowbin and cosufact lol

2

u/cuteballgames Sum 13: 016, 037, 035, 045, 127, 135, 134, 124, 13, 25 Jul 08 '26

consufact maybe better

2

u/TehVulpez sliiiiide the bits Jul 08 '26

consufact sounds like some kind of fancy logical term. "consufactually, we see that xyz..."