Given two numbers (m and n) :

- convert all numbers from m to n to binary
- sum them as if they were in base 10 
- convert the result to binary
- return as string

Eg: with the numbers 1 and 4


   1 // 1 to binary is 1
+ 10 // 2 to binary is 10
+ 11 // 3 to binary is 11
+100 // 4 to binary is 100
----
 122 // 122 in Base 10 to Binary is 1111010



So BinaryPyramid ( 1 , 4 ) should return "1111010" 

range should be ascending in order

Source: codewars | Difficulty: EASY
Tags: Fundamentals

Mathematics

Starter code: def binary_pyramid(m,n):
	

Solutions:
def binary_pyramid(m, n):
	return bin(sum((int(bin(i)[2:]) for i in range(m, n + 1))))[2:]


def binary_pyramid(m, n):
	return '{:b}'.format(sum(map(int, map('{:b}'.format, range(m, n + 1)))))


binary_pyramid = lambda m, n: bin(sum((int(bin(e)[2:]) for e in range(m, n + 1))))[2:]


def binary_pyramid(m, n):
	return format(sum((int(format(i, 'b')) for i in range(m, n + 1))), 'b')


def binary_pyramid(m, n):
	sm = 0
	for i in range(m, n + 1):
		sm += int('{0:b}'.format(i))
	return '{0:b}'.format(sm)


def binary_pyramid(m, n):
	return f"{sum((int(f'{x:b}') for x in range(m, n + 1))):b}"


binary_pyramid = lambda a, b: bin(sum((int(bin(n)[2:]) for n in range(a, b + 1))))[2:]