You are given two positive integers ```a``` and ```b```.

You can perform the following operations on ```a``` so as to obtain ```b``` :
```
(a-1)/2   (if (a-1) is divisible by 2)
a/2       (if a is divisible by 2)
a*2
```
```b``` will always be a power of 2.

You are to write a function ```operation(a,b)``` that efficiently returns the minimum number of operations required to transform ```a``` into ```b```.

For example :
```
operation(2,8) -> 2
2*2 = 4
4*2 = 8

operation(9,2) -> 2
(9-1)/2 = 4
4/2 = 2

operation(1024,1024) -> 0
```

Difficulty: EASY
Starter code: def operation(a,b):
	

Solutions:
from math import log2

def operation(a, b, n=0):
	while log2(a) % 1:
		n += 1
		a //= 2
	return n + abs(log2(a / b))


def operation(a, b):
	res = 0
	while a != 1 << a.bit_length() - 1:
		(a, res) = (a >> 1, res + 1)
	return res + abs(a.bit_length() - b.bit_length())


from math import log2

def operation(a, b):
	if log2(a).is_integer():
		return abs(log2(a) - log2(b))
	return 1 + operation(a // 2, b)


def operation(a, b):
	return 0 if a == b else 1 + (operation(a // 2, b) if a > b else operation(a, b // 2))


def is_power(n):
	if n != int(n):
		return False
	if n == 1:
		return True
	elif n > 1:
		return is_power(n / 2)
	else:
		return False

def operation(a, b):
	num_operation = 0
	while a > b or is_power(a) is not True:
		if a % 2 != 0:
			a = (a - 1) / 2
			num_operation += 1
		else:
			a = a / 2
			num_operation += 1
	while a < b:
		a = a * 2
		num_operation += 1
	return num_operation


from math import log2

def operation(a, b):
	if a in (0, b):
		return 0
	c = 0
	while a != b:
		if a % 2 and a > 1:
			a = (a - 1) // 2
		elif a < b and log2(a).is_integer():
			a *= 2
		elif a > b or not log2(a).is_integer():
			a //= 2
		c += 1
	return c


from math import log2

def operation(a, b):
	c = 0
	while 2 ** int(log2(a)) != a and a > 1:
		a //= 2
		c += 1
	return c + abs(int(log2(b) - log2(a)))


from math import log2

def operation(a, b):
	i = 0
	while log2(a) != int(log2(a)):
		a //= 2
		i += 1
	return i + abs(log2(a) - log2(b))


def operation(a, b):
	count = 0
	while a != b:
		while a != 1 and a & a - 1:
			a //= 2
			count += 1
		if a < b:
			a *= 2
			count += 1
		elif a > b:
			a //= 2
			count += 1
	return count