## Number pyramid

Number pyramid is a recursive structure where each next row is constructed by adding adjacent values of the current row. For example:

```
Row 1     [1     2     3     4]
Row 2        [3     5     7]
Row 3           [8    12]
Row 4             [20]
```

___

## Task

Given the first row of the number pyramid, find the value stored in its last row.

___

## Examples

```python
reduce_pyramid([1])        ==  1
reduce_pyramid([3, 5])     ==  8
reduce_pyramid([3, 9, 4])  ==  25
```

___

## Performance tests

```python
Number of tests: 10
List size: 10,000
```

Source: codewars | Difficulty: EASY

Starter code: def reduce_pyramid(base):
	

Solutions:
from operator import mul

def reduce_pyramid(base):
	return sum(map(mul, base, comb_n(len(base) - 1)))

def comb_n(n):
	c = 1
	for k in range(0, n + 1):
		yield c
		c = c * (n - k) // (k + 1)


def reduce_pyramid(base):
	(c, t, ll) = (1, 0, len(base) - 1)
	for (i, v) in enumerate(base):
		t += c * v
		c = c * (ll - i) // (i + 1)
	return t


def reduce_pyramid(base):
	(s, c) = (0, 1)
	for (i, x) in enumerate(base, 1):
		s += c * x
		c = c * (len(base) - i) // i
	return s


def reduce_pyramid(base):
	(tot, c, n) = (0, 1, len(base) - 1)
	for i in range(n + 1 >> 1):
		tot += c * (base[i] + base[n - i])
		c = c * (n - i) // (i + 1)
	if not n & 1:
		tot += c * base[n >> 1]
	return tot


def _coefs(l):
	n = 1
	for i in range(l):
		yield n
		n = n * (l - i - 1) // (i + 1)
	yield n

def reduce_pyramid(base):
	coefs = _coefs(len(base))
	return sum((next(coefs) * n for n in base))


def reduce_pyramid(Q):
	(R, U) = (0, 1)
	for (F, V) in enumerate(Q):
		(R, U) = (R + V * U, U * (len(Q) + ~F) // -~F)
	return R


def reduce_pyramid(base):
	(n, c, r) = (len(base) - 1, 1, 0)
	for (i, x) in enumerate(base):
		r += c * x
		c = c * (n - i) // (i + 1)
	return r


def pascal(n):
	line = [1]
	for k in range(n):
		line.append(line[k] * (n - k) // (k + 1))
	return line

def reduce_pyramid(a):
	x = len(a) - 1
	C = pascal(x)
	s = 0
	for (i, v) in enumerate(a):
		s += C[i] * v
	return s


def reduce_pyramid(base):
	sm = 0
	nb = 1
	for (i, u) in enumerate(base, 1):
		sm += nb * u
		nb = nb * (len(base) - i) // i
	return sm


def reduce_pyramid(b):
	(p, r) = (1, b[0])
	for i in range(1, len(b)):
		p = p * (len(b) - i) // i
		r += b[i] * p
	return r