bit.py
class Bitutils():
def bitSwapRequired(self,a,b):
count = 0
c = a ^ b
while c != 0:
if c and 1 != 0:
count += 1
c >>= 1
return count
def swapOddEvenBits(self,x):
even = (x & 0b10101010 >> 1)
odd = (x & 0b01010101 << 1)
return even or odd
A function that swaps even and odd bits It's easy to do