human
Count positions in Binary Matrix having equal count of set bits in corresponding row and column | Function to return the count of indices in from the given binary matrix having equal count of set bits in its row and column.
Stores count of set bits in corresponding column and row.
Traverse matrix.
Since 1 contains a set bit.
Update count of set bits for current row and col.
Stores the count of required indices.
Traverse matrix.
If current row and column has equal count of set bits.
Return count of required position.
Driver Code"
How can the above be solved in Python?
 ... Can you provide a code to count positions in Binary Matrix having equal count of set bits in corresponding row and column and the other steps required?
assistant
#Here is code to count positions in Binary Matrix having equal count of set bits in corresponding row and column and the other steps required.
 def countPosition ( mat ) :
	n = len ( mat )
	m = len ( mat [ 0 ] )
	row = [ 0 ] * n
	col = [ 0 ] * m
	for i in range ( n ) :
		for j in range ( m ) :
			if ( mat [ i ] [ j ] == 1 ) :
				col [ j ] += 1
				row [ i ] += 1
	count = 0
	for i in range ( n ) :
		for j in range ( m ) :
			if ( row [ i ] == col [ j ] ) :
				count += 1
	return count
mat = [ [ 0 , 1 ] , [ 1 , 1 ] ]
print ( countPosition ( mat ) )