*Inspired by the [Fold an Array](https://www.codewars.com/kata/fold-an-array) kata. This one is sort of similar but a little different.*

---

## Task
You will receive an array as parameter that contains 1 or more integers and a number `n`.

Here is a little visualization of the process:

* Step 1: Split the array in two:
```
  [1, 2, 5, 7, 2, 3, 5, 7, 8]
        /            \
[1, 2, 5, 7]    [2, 3, 5, 7, 8]
```

* Step 2: Put the arrays on top of each other:
```
     [1, 2, 5, 7]
[2, 3, 5, 7, 8]
```

* Step 3: Add them together:
```
[2, 4, 7, 12, 15]
```



Repeat the above steps `n` times or until there is only one number left, and then return the array.


## Example

```
Input: arr=[4, 2, 5, 3, 2, 5, 7], n=2


Round 1
-------
step 1: [4, 2, 5]  [3, 2, 5, 7]

step 2:    [4, 2, 5]
        [3, 2, 5, 7]

step 3: [3, 6, 7, 12]


Round 2
-------
step 1: [3, 6]  [7, 12]

step 2:  [3,  6]
         [7, 12]

step 3: [10, 18]


Result: [10, 18]
```

Difficulty: introductory

Starter code:

def split_and_add(numbers, n):
	

Solutions:
def split_and_add(numbers, n):
    for _ in range(n):
        middle = len(numbers) // 2
        left = numbers[:middle]
        right = numbers[middle:]
        numbers = [a + b for a, b in zip((len(right) - len(left)) * [0] + left, right)]
        if len(numbers) == 1:
            return numbers
    return numbers


def split_and_add(arr, n):
    for _ in range(n):
        half = len(arr) // 2
        arr = [a+b for a, b in zip([0] * (len(arr)%2) + arr[:half], arr[half:])]
    
    return arr

from itertools import starmap
from operator import add

def split_and_add(numbers, n):
    for __ in range(n):
        mid, uneven = divmod(len(numbers), 2)
        numbers = list(starmap(add, zip([0] * uneven + numbers[:mid], numbers[mid:])))
    return numbers

from itertools import zip_longest

def split_and_add(xs, n):
  return split_and_add([(a or 0) + b for a, b in zip_longest(xs[:len(xs)//2][::-1], xs[len(xs)//2:][::-1])][::-1], n-1) if n else xs

def split_and_add(a, n):    
    return split_and_add([sum(e) for e in zip(([0] if len(a) % 2 else []) + a[:len(a)//2], a[len(a)//2:])], n - 1) if n else a

from itertools import zip_longest

def split_and_add(numbers, n):
    while len(numbers) > 1 and n:
        n -= 1
        m = len(numbers) // 2
        it = zip_longest(reversed(numbers[:m]), reversed(numbers[m:]), fillvalue=0)
        numbers = list(map(sum, it))[::-1]
    return numbers

def split_and_add(numbers, n):
    def splitter(arr):
        left, right = ([0] if len(arr) % 2 != 0 else []) + arr[:len(arr)//2], arr[len(arr)//2:]
        return [l + r for l, r in zip(left, right)]
    return numbers if n == 0 else split_and_add(splitter(numbers), n - 1)

def split_and_add(numbers, n):
    arr = numbers[:]
    for _ in range(n):
        mid, rest = divmod(len(arr), 2)
        arr = [a + b for a, b in zip(rest * [0] + arr[:mid], arr[mid:])]
    return arr

def split_and_add(numbers, n):
    for _ in range(n):
        m, r = divmod(len(numbers), 2)
        numbers = list(map(sum, zip(r * [0] + numbers[:m], numbers[m:])))
    return numbers

def split_and_add(numbers, n):
    from itertools import zip_longest
    for i in range(n):
        length = len(numbers)//2
        numbers = list(reversed([x+y for x,y in zip_longest(reversed(numbers[0:length]), reversed(numbers[length:]), fillvalue=0)]))
    return numbers