The objective is to write a method that takes two integer parameters and returns a single integer equal to the number of 1s in the binary representation of the greatest common divisor of the parameters. 

Taken from Wikipedia:
"In mathematics, the greatest common divisor (gcd) of two or more integers, when at least one of them is not zero, is the largest positive integer that divides the numbers without a remainder. For example, the GCD of 8 and 12 is 4."

For example: the greatest common divisor of 300 and 45 is 15. The binary representation of 15 is 1111, so the correct output would be 4.

If both parameters are 0, the method should return 0.
The function must be able to handle negative input.

Source: codewars | Difficulty: EASY
Tags: Bit manipulation

Starter code: def binary_gcd(x, y):
	

Solutions:
from fractions import gcd

def binary_gcd(x, y):
	return bin(gcd(x, y)).count('1')


def binary_gcd(x, y):
	import math
	return bin(math.gcd(x, y)).count('1')


def binary_gcd(x, y):
	if x == 0 and y == 0:
		return 0

	def gcd(a, b):
		if b == 0:
			return a
		return gcd(b, a % b)
	return sum((c == '1' for c in bin(gcd(x, y))[2:]))


from fractions import gcd

def binary_gcd(x, y):
	if not (x or y):
		bin(max(x, y)).count('1')
	return bin(gcd(x, y)).count('1')


import fractions

def binary_gcd(x, y):
	output = bin(fractions.gcd(x, y))
	return output.count('1')


def binary_gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	binaryx = bin(abs(x))
	bingcd = binaryx.replace('0b', '')
	return sum((int(i) for i in bingcd))


def check(n):
	set1 = set()
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			set1.add(i)
			set1.add(n // i)
	return set1

def binary_gcd(x, y):
	if x == 0 and y == 0:
		return 0
	elif x == 0 and y != 0:
		a = y
	elif y == 0 and x != 0:
		a = x
	else:
		a = max(check(abs(x)) & check(abs(y)))
	num = 0
	while a != 0:
		a = a & a - 1
		num += 1
	return num


from math import gcd

def binary_gcd(x, y):
	return sum((1 for x in bin(gcd(x, y)) if x == '1'))


def binary_gcd(x, y):
	if x == 0 and y == 0:
		return 0
	elif x == 0 or y == 0:
		return bin(max(abs(x), abs(y))).count('1')
	for i in range(min(abs(x), abs(y)), 0, -1):
		if x % i == 0 and y % i == 0:
			return bin(i).count('1')