#Python code for A379277 by John Rascoe 12/19/24
from numpy import sum as nsum, zeros

def comp(n): #n-th composition in stadard order after F.T.A in A066099
    v,k = [],0
    while n > 0:
        k += 1
        if n%2 == 1:
            v.append(k)
            k = 0
        n = n//2
    return(tuple(v[::-1]))

def build(i,v,b): #build function outputs a list of planar partitions as np arrays
    A = [[b]]
    if i == 1:
        z = zeros(b.shape, dtype=int)
        z[0,0] += 1
        A = [[z]]
        st = 0
    else:
        st = 1
    for j in range(1,v+st):
        S = set()
        A.append([])
        def addp(u):
            nk = u.copy()
            nk[x,y] += 1
            nkt = tuple(map(tuple, nk))
            if nkt not in S:
                S.add(nkt)
                A[j].append(nk)
        for k in A[j-1]:
            wb = len(b)
            for x in range(wb):
                if x == 0:
                    for y in range(wb):
                        if y == 0: #adds one to the top left corner 
                            addp(k)
                        if y > 0: #checks the top row
                            if (k[x,y] + 1) <= k[x,y-1]:
                                addp(k)
                        if k[x,y] == 0: #breaks once a zero is reached
                                break
                elif k[x,0] > 0: #checks internal rows starting at index 1
                    for y in range(1,wb):
                        if (k[x,y] +1) <= k[x,y-1] and (k[x,y] +1) <= k[x-1,y]:
                            addp(k)
                        if k[x,y] == 0:
                            break        
            for x in range(1,wb): #checks the first column
                y = 0
                if (k[x,0]+1) <= k[x-1,0]:
                    addp(k)
                if k[x,0] == 0:
                    break    
    return A[-1]   

def mult(c): #returns the number of solid partitions for a given multiplicity tuple c
    A = [[]]
    z = sum(c)
    a = zeros((z+1,z+1), dtype=int)
    A[0].append(a)
    for i in range(len(c)):
        A.append([])
        for j in A[i]:
            A[i+1].extend(build(i+1,c[i],j))
    return(len(A[-1]))

def A379277(n):
    return mult(comp(n))