Given an array of ones and zeroes, convert the equivalent binary value to an integer.

Eg: `[0, 0, 0, 1]` is treated as `0001` which is the binary representation of `1`.

Examples:
```
Testing: [0, 0, 0, 1] ==> 1
Testing: [0, 0, 1, 0] ==> 2
Testing: [0, 1, 0, 1] ==> 5
Testing: [1, 0, 0, 1] ==> 9
Testing: [0, 0, 1, 0] ==> 2
Testing: [0, 1, 1, 0] ==> 6
Testing: [1, 1, 1, 1] ==> 15
Testing: [1, 0, 1, 1] ==> 11
```

However, the arrays can have varying lengths, not just limited to `4`.

Difficulty: EASY
Tags: Fundamentals

Data structures
Skill types: Data structures

Starter code:
def binary_array_to_number(arr):
	

Solutions:
def binary_array_to_number(arr):
	return int(''.join(map(str, arr)), 2)


def binary_array_to_number(arr):
	return int(''.join((str(a) for a in arr)), 2)


def binary_array_to_number(arr):
	s = 0
	for digit in arr:
		s = s * 2 + digit
	return s


def binary_array_to_number(arr):
	return sum((digit * 2 ** i for (i, digit) in enumerate(reversed(arr))))


def binary_array_to_number(arr):
	return sum((2 ** i for (i, n) in enumerate(arr[::-1]) if n))


from functools import reduce

def binary_array_to_number(arr):
	append_bit = lambda n, b: n << 1 | b
	return reduce(append_bit, arr)


def binary_array_to_number(arr):
	no_of_elements = len(arr)
	k = no_of_elements
	sum = 0
	while k != 0:
		sum = sum + arr[no_of_elements - k] * 2 ** (k - 1)
		k = k - 1
	return sum


def binary_array_to_number(arr):
	if type(arr) is list and len(arr) > 0:
		return int(''.join((str(e) for e in arr)), 2)
	return -1


def binary_array_to_number(arr):
	return int(bytearray(''.join((str(a) for a in arr)), encoding='utf-8'), base=2)


binary_array_to_number = lambda arr: int(''.join(map(str, arr)), 2)


from functools import reduce

def binary_array_to_number(a):
	return reduce(lambda t, b: t * 2 + b, a)


def binary_array_to_number(arr):
	return sum((item * 2 ** index for (index, item) in enumerate(reversed(arr))))


def binary_array_to_number(arr):
	binary = ''.join([str(n) for n in arr])
	return int(binary, 2)


def binary_array_to_number(arr):
	res = 0
	arr.reverse()
	for index in range(len(arr)):
		res += arr[index] * pow(2, index)
	return res


def binary_array_to_number(arr):
	res = 0
	li = [x for x in reversed(arr)]
	print(li)
	for i in range(len(li)):
		if li[i] == 1:
			res = res + 2 ** i
	return res


import re

def binary_array_to_number(arr):
	binaryString = ''.join(re.findall('\\d', str(arr)))
	return int(binaryString, 2)


def binary_array_to_number(arr):
	strng = ' '
	for nr in arr:
		strng = strng + str(nr)
	return int(strng, 2)


def binary_array_to_number(arr, acc=0):
	if len(arr) == 0:
		return acc
	acc = acc << 1 | arr.pop(0)
	return binary_array_to_number(arr, acc)


def binary_array_to_number(arr):
	return sum((value * 2 ** index for (index, value) in enumerate(arr[::-1])))


def binary_array_to_number(arr):
	return int(''.join((str(i) for i in arr)), 2)


def binary_array_to_number(arr):
	sum = 0
	for i in range(0, len(arr)):
		sum += arr[i] * 2 ** (len(arr) - 1 - i)
	return sum


def binary_array_to_number(arr):
	return int(''.join((str(x) for x in arr)), 2)


binary_array_to_number = lambda a: int(''.join(map(str, a)), 2)


def binary_array_to_number(arr):
	binary = ''.join(map(str, arr))
	ans = 0
	for i in range(len(binary)):
		ans += int(binary[i]) * 2 ** (len(binary) - i - 1)
	return ans


def binary_array_to_number(arr):
	total = 0
	for n in range(len(arr)):
		if arr[n] == 1:
			total += pow(2, len(arr) - 1 - n)
	return total


def binary_array_to_number(arr):
	arr = arr[::-1]
	sumador = 0
	for i in range(len(arr)):
		if arr[i] == 1:
			sumador += 2 ** i
		else:
			continue
	return sumador


def binary_array_to_number(arr):
	a = len(arr)
	n = 0
	for i in range(len(arr)):
		a -= 1
		if arr[i] == 1:
			n += 2 ** a
	return n


def binary_array_to_number(arr):
	decimal = 0
	p = 0
	for x in reversed(arr):
		decimal += x * 2 ** p
		p += 1
	return decimal


def binary_array_to_number(arr):
	binarr = ''
	for i in arr:
		binarr = binarr + str(i)
	return int(binarr, 2)