You have been tasked with converting a number from base i (sqrt of -1) to base 10. 

Recall how bases are defined: 

    abcdef = a * 10^5 + b * 10^4 + c * 10^3 + d * 10^2 + e * 10^1 + f * 10^0

Base i follows then like this:

    ... i^4 + i^3 + i^2 + i^1 + i^0

The only numbers in any place will be 1 or 0
Examples:
  101 in base i would be:
    
      1 * i^2 + 0 * i^1 + 1*i^0 = -1 + 0 + 1 = 0
      
  10010 in base i would be:
    
      1*i^4 + 0 * i^3 + 0 * i^2 + 1 * i^1 + 0 * i^0 = 1 + -i = 1-i

You must take some number, n, in base i and convert it into a number in base 10, in the format of a 2x1 vector.

    [a,b] = a+b*i
    
The number will always be some combination of 0 and 1

In Python you will be given an integer.
In Javascript and C++ you will be given a string

Source: codewars | Difficulty: EASY
Tags: Mathematics

Starter code: def convert(n):
	

Solutions:
def convert(n):
	ds = list(map(int, reversed(str(n))))
	return [sum(ds[::4]) - sum(ds[2::4]), sum(ds[1::4]) - sum(ds[3::4])]


def convert(n):
	s = str(n)[::-1]
	return [sum((p * s[i - p::4].count('1') for p in (1, -1))) for i in (1, 2)]


def convert(n):
	result = sum((1j ** i for (i, x) in enumerate(str(n)[::-1]) if x == '1'))
	return [result.real, result.imag]


def convert(n):
	ls = [int(j) if i % 4 <= 1 else -int(j) for (i, j) in enumerate(str(n)[::-1])]
	return [sum(ls[::2]), sum(ls[1::2])]


from itertools import cycle

def convert(n):
	(c, i, val) = (cycle([1, 1, -1, -1]), cycle([0, 1]), [0, 0])
	for l in str(n)[::-1]:
		val[next(i)] += next(c) * (l == '1')
	return val


def convert(n):
	res = sum((x * 1j ** i for (i, x) in enumerate(map(int, str(n)[::-1]))))
	return [res.real, res.imag]


def convert(n):
	b = 1
	s = 0
	while n > 0:
		if n % 10 == 1:
			s += b
		n //= 10
		b *= 1j
	return [int(s.real), int(s.imag)]


def convert(n):
	base = 1j
	val = 0
	for c in str(n):
		val *= base
		val += int(c)
	return [val.real, val.imag]


def convert(n):
	r = [0, 0]
	for (i, d) in enumerate(str(n)[::-1]):
		if i % 4 == 0:
			r[0] += int(d)
		elif i % 4 == 2:
			r[0] -= int(d)
		elif i % 4 == 1:
			r[1] += int(d)
		else:
			r[1] -= int(d)
	return r


def convert(n):
	s = str(n)[::-1]
	p = [s[i::4].count('1') for i in range(4)]
	return [p[0] - p[2], p[1] - p[3]]