# Description

Given a number `n`, you should find a set of numbers for which the sum equals `n`. This set must consist exclusively of values that are a power of `2` (eg: `2^0 => 1, 2^1 => 2, 2^2 => 4, ...`).

The function `powers` takes a single parameter, the number `n`, and should return an array of unique numbers.

## Criteria

The function will always receive a valid input: any positive integer between `1` and the max integer value for your language (eg: for JavaScript this would be `9007199254740991` otherwise known as `Number.MAX_SAFE_INTEGER`).

The function should return an array of numbers that are a **power of 2** (`2^x = y`).

Each member of the returned array should be **unique**. (eg: the valid answer for `powers(2)` is `[2]`, not `[1, 1]`)

Members should be sorted in **ascending order** (small -> large). (eg: the valid answer for `powers(6)` is `[2, 4]`, not `[4, 2]`)

Difficulty: EASY
Starter code: def powers(n):
	

Solutions:
def powers(n):
	return [1 << i for (i, x) in enumerate(reversed(bin(n))) if x == '1']


def powers(n):
	return [2 ** i for (i, d) in enumerate(f'{n:b}'[::-1]) if d == '1']


def powers(n):
	tmp = []
	i = 0
	res = []
	while 2 ** i <= n:
		tmp.append(2 ** i)
		i += 1
	for j in tmp[::-1]:
		if n >= j:
			res.append(j)
			n -= j
	return res[::-1]


def powers(n):
	s = bin(n)[::-1]
	return [2 ** i for (i, x) in enumerate(s) if x == '1']


pows = [2 ** i for i in range(63, -1, -1)]

def powers(n):
	result = []
	for p in pows:
		if n >= p:
			result.append(p)
			n -= p
	return result[::-1]


powers = lambda n: [1 << i for i in range(n.bit_length()) if 1 << i & n]


def powers(n):
	return [d << p for (p, d) in enumerate(map(int, reversed(f'{n:b}'))) if d]


def powers(n):
	return [2 ** i for (i, k) in enumerate(bin(n)[::-1]) if k == '1']


def powers(n):
	next_small = n.bit_length()
	(total, lst) = (0, [])
	while next_small > -1:
		v = 1 << next_small
		if total + v <= n:
			total += v
			lst.append(v)
		if total == n:
			break
		next_small -= 1
	return lst[::-1]