human
Count trailing zero bits using lookup table | Python3 code for counting trailing zeros in binary representation of a number.
Map a bit value mod 37 to its position.
Only difference between ( x and - x ) is the value of signed magnitude ( leftmostbit ) negative numbers signed bit is 1.
Driver Code"
How can the above be solved in Python?
assistant
#Here is code to count trailing zero bits using lookup table and the other steps required.
 def countTrailingZero ( x ) :
	lookup = [ 32 , 0 , 1 , 26 , 2 , 23 , 27 , 0 , 3 , 16 , 24 , 30 , 28 , 11 , 0 , 13 , 4 , 7 , 17 , 0 , 25 , 22 , 31 , 15 , 29 , 10 , 12 , 6 , 0 , 21 , 14 , 9 , 5 , 20 , 8 , 19 , 18 ]
	return lookup [ ( - x & x ) % 37 ]
if __name__ == " _ _ main _ _ " :
	print ( countTrailingZero ( 48 ) )