I'll be given lines like 12345678*987654321 and then I will be given a number of nodes per digit, so if that number was 3 the numbers would be ["012", "345", "678"] and ["987", "654", "321"] (I add zeroes at beginning to get correct number of digits).

I then have to add/multiply them together. I have everything done up to that point, I'm just having trouble with the add/mult.

For the multiplication I am allowed to recombine the nodes into one number again, but then I have to multiply recursively.

I have this function:

def mult(x,y): if(y == 0): return 0 return x + mult(x, y-1)

but it doesn't work with large functions (reaches maximum recursion depth)

I have this for add:

def recursive_sum(l1, l2, idx = 0): if idx < min(len(l1), len(l2)): return [int(l1[idx]) + int(l2[idx])] + recursive_sum(l1, l2, idx + 1) else: return []

This works somewhat, but it turns ['001', '234', '567'], '+', ['007', '894', '561'] into [8,1128,1128], the answer is 9128128 so it works but it doesn't deal with carryout. It also doesn't work if the two lists don't have the same number of elements.