human
Check if a number has same number of set and unset bits | Function to check if a number has same setbits and unset bits.
iterate for all bits of a number.
if set.
if unset.
right shift number by 1.
is number of set bits are equal to unset bits.
Driver Code.
function to check"
Solution in Python:

Can you provide a code to check if a number has same number of set and unset bits and the other steps required?
assistant
#Here is code to check if a number has same number of set and unset bits and the other steps required.
 def checkSame ( n ) :
	set , unset = 0 , 0
	while ( n ) :
		if ( n and 1 ) :
			set + 1
		else :
			unset += 1
		n = n >> 1
	if ( set == unset ) :
		return True
	else :
		return False
if __name__ == ' _ _ main _ _ ' :
	n = 12
	if ( checkSame ( n ) ) :
		print ( " YES " )
	else :
		print ( " NO " )