human
Change all even bits in a number to 0 | Returns modified number with all even bits 0..
To store sum of bits at even positions ..
To store bits to shift.
One by one put all even bits to end.
If current last bit is set , add it to ans.
Next shift position.
Driver code"
Solution in Python:
assistant
#Here is code to change all even bits in a number to 0 and the other steps required.
 def changeEvenBits ( n ) :
	to_subtract = 0
	m = 0
	x = n
	while ( x ) :
		if ( x & 1 ) :
			to_subtract += ( 1 << m )
		m += 2
		x >>= 2
	return n - to_subtract
n = 30
print changeEvenBits ( n )