Build a function `sumNestedNumbers`/`sum_nested_numbers` that finds the sum of all numbers in a series of nested arrays raised to the power of their respective nesting levels.  Numbers in the outer most array should be raised to the power of 1.

For example,

should return `1 + 2*2 + 3 + 4*4 + 5*5*5 === 149`

Difficulty: introductory

Starter code:

def sum_nested_numbers(a, depth=1):
	

Solutions:
def sum_nested_numbers(a, depth=1):
    return sum(sum_nested_numbers(e, depth+1) if type(e) == list else e**depth for e in a)

def sum_nested_numbers(arr,m=1):
    total = 0
    for element in arr:
        if isinstance(element, int): 
            total += element**m
        else:
            total += sum_nested_numbers(element, m+1)
    return total

def sum_nested_numbers(a, lvl=0):
    return a ** lvl if not isinstance(a, list) else sum(sum_nested_numbers(b, lvl+1) for b in a)

def sum_nested_numbers(arr, depth = 1):
  return sum(sum_nested_numbers(x, depth+1) if type(x) is list else x ** depth for x in arr)

def flatten(xs, level=1):
    for x in xs:
        if isinstance(x, list):
            yield from flatten(x, level+1)
        else:
            yield x, level

def sum_nested_numbers(xs):
    return sum(x ** level for x, level in flatten(xs))

def depth(arr,n):
    res=[]
    for i in arr:
        if isinstance(i,int):
            res.append((i,n))
        else:
            res+=depth(i,n+1)
    return res
def sum_nested_numbers(arr):
    return sum(n**i for (n,i) in depth(arr,1))

def sum_nested_numbers(x):
    return sum(f(x))

def f(lst, v=1):
    for x in lst:
        if isinstance(x, (list,tuple)):
            for j in f(x, v+1):
                yield j
        else:
            yield x**v

sum_nested_numbers=r=lambda a,p=1:sum(n**p if n*0==0else r(n,p+1)for n in a)

def sum_nested_numbers(arr, d=1):
    my_sum = 0
    for v in arr:
        if isinstance(v, list):
            my_sum += sum_nested_numbers(v, d+1)
        else:
            my_sum += (v**d)
    return my_sum