# SageMath code for A330794 in one unit.
# code based on Peter Luschny's work


max = 20 # number of rows of the matrix

def riordan_array(d, h, n, exp=false):
    def taylor_list(f, n):
        t = SR(f).taylor(x, 0, n-1).list()
        return t + [0]*(n-len(t))
    td = taylor_list(d, n)
    th = taylor_list(h, n)
    M = matrix(QQ, n, n)
    for k in (0..n-1): M[k, 0] = td[k]
    for k in (1..n-1):
        for m in (k..n-1):
            M[m, k] = add(M[j, k-1]*th[m-j] for j in (k-1..m-1))
    if exp:
        u = 1
        for k in (1..n-1):
            u *= k
            for m in (0..k):
                j = u if m==0 else j/m
                M[k, m] *= j
    return M
riordan_array(1, 1/(2-exp(x)) - 1, 8, exp=true)

def riordan_square(gf, len, exp=false):
    return riordan_array(gf, gf, len, exp)

# A322942 = riordan_square((1 - 2*x^2)/((1 + x)*(1 - 2*x)), max+2) 
A330794 = riordan_square((1 - 2*x^2)/((1 + x)*(1 - 2*x)), max+2).inverse() # inverse of A322942

# [[A330794[n,k] for k in range(n+1)] for n in range(max+1)] # triangle form of A330794
flatten([[A330794[n,k] for k in range(n+1)] for n in range(max+1)]) # flattened triangle