human
Check if a number has bits in alternate pattern | Set 1 | Returns true if n has alternate bit pattern else false.
Store last bit.
Traverse through remaining bits.
If current bit is same as previous.
Driver code"
Solution in Python:
 Give me a code to check if a number has bits in alternate pattern and the other steps required?
assistant
#Here is code to check if a number has bits in alternate pattern and the other steps required.
 def findPattern ( n ) :
	prev = n % 2
	n = n // 2
	while ( n > 0 ) :
		curr = n % 2
		if ( curr == prev ) :
			return False
		prev = curr
		n = n // 2
	return True
n = 10
print ( " Yes " ) if ( findPattern ( n ) ) else print ( " No " )