def add(poly0, poly1, nmax):
    lp0 = len(poly0.coeffs)
    lp1 = len(poly1.coeffs)
    p0 = min(poly0.p0, poly1.p0)
    n = min(max(poly0.p0 + lp0, poly1.p1 + lp1), nmax) - p0
    if n <= 0: return Poly(0, [])
    coeffs = []
    for i in range(n):
        c = 0
        if i >= poly0.p0 - p0 and i < lp0 + poly0.p0 - p0:
            c += poly0.coeffs[i + p0 - poly0.p0]
        if i >= poly1.p0 - p0 and i < lp1 + poly1.p0 - p0:
            c += poly1.coeffs[i + p0 - poly1.p0]
        coeffs.append(c)
    return Poly(p0, coeffs)
dataset/ETHPy150Open google/roboto/third_party/spiro/curves/numintsynth.py/add/original