# Task
 Given an array of 2^(k) integers (for some integer `k`), perform the following operations until the array contains only one element:
```
On the 1st, 3rd, 5th, etc. 
iterations (1-based) replace each pair of consecutive elements with their sum;
On the 2nd, 4th, 6th, etc. 
iterations replace each pair of consecutive elements with their product.
```
After the algorithm has finished, there will be a single element left in the array. Return that element.

# Example

 For inputArray = [1, 2, 3, 4, 5, 6, 7, 8], the output should be 186.

 We have `[1, 2, 3, 4, 5, 6, 7, 8] -> [3, 7, 11, 15] -> [21, 165] -> [186]`, so the answer is 186.

# Input/Output

 - `[input]` integer array `arr`

   Constraints: 2^(1) ≤ arr.length ≤ 2^(5), -9 ≤ arr[i] ≤ 99.

 - `[output]` an integer

Source: codewars | Difficulty: EASY
Tags: Ad-hoc

Starter code: def array_conversion(arr):
	

Solutions:
def array_conversion(arr):
	sign = 0
	while len(arr) > 1:
		sign = 1 ^ sign
		arr = list(map(lambda x, y: x + y, arr[0::2], arr[1::2]) if sign else map(lambda x, y: x * y, arr[0::2], arr[1::2]))
	return arr[0]


array_conversion = c = lambda a, p=0: a[1:] and c([[x + y, x * y][p] for (x, y) in zip(*[iter(a)] * 2)], 1 - p) or a[0]


def array_conversion(l):
	iter = 0
	while len(l) > 1:
		iter += 1
		l = [[l[i] * l[i + 1], l[i] + l[i + 1]][iter % 2] for i in range(0, len(l) - 1, 2)]
	return l[0]


from itertools import count

def array_conversion(arr):
	for i in count(1):
		it = iter(arr)
		arr = [a + b if i % 2 else a * b for (a, b) in zip(it, it)]
		if len(arr) == 1:
			return arr.pop()


from operator import add, mul
from itertools import count

def array_conversion(arr):
	for i in count():
		if len(arr) == 1:
			return arr[0]
		arr = list(map((add, mul)[i & 1], arr[::2], arr[1::2]))


from operator import add, mul

def array_conversion(a):
	(i, f) = (1, [mul, add])
	while len(a) > 1:
		a = [f[i](x, y) for (x, y) in zip(a[::2], a[1::2])]
		i ^= 1
	return a[0]


from operator import add, mul

def array_conversion(arr):
	iteration = 0
	while len(arr) > 1:
		iteration += 1
		arr = [(add if iteration & 1 else mul)(a, b) for (a, b) in zip(arr[::2], arr[1::2])]
	return arr[0]


def array_conversion(arr):
	ops = [int.__mul__, int.__add__]
	c = 1
	while len(arr) != 1:
		arr = [ops[c](x, y) for (x, y) in zip(arr[::2], arr[1::2])]
		c = 1 - c
	return arr[0]


def array_conversion(a, add=True):
	while len(a) > 1:
		a = [x + y if add else x * y for (x, y) in zip(*[iter(a)] * 2)]
		add = not add
	return a[0]


from math import log2

def array_conversion(arr):
	for it in range(int(log2(len(arr)))):
		arr = [arr[i] * arr[i + 1] if it % 2 else arr[i] + arr[i + 1] for i in range(0, len(arr), 2)]
	return arr[0]