human
Give me a code to check if rows of a Matrix can be rearranged to make Bitwise XOR of first column non and the other steps required given the following:
Check if rows of a Matrix can be rearranged to make Bitwise XOR of first column non | Function to check if there is any row where number of unique elements are greater than 1.
Iterate over the matrix.
Function to check if it is possible to rearrange mat [ ] [ ] such that XOR of its first column is non - zero.
Find bitwise XOR of the first column of mat [ ] [ ].
If bitwise XOR of the first column of mat [ ] [ ] is non - zero.
Otherwise check rearrangements.
Driver Code.
Given Matrix mat [ ] [ ].
Function Call"
How can the above be solved in Python?
assistant
#Here is code to check if rows of a Matrix can be rearranged to make Bitwise XOR of first column non and the other steps required.
 def checkRearrangements ( mat , N , M ) :
	for i in range ( N ) :
		for j in range ( 1 , M ) :
			if ( mat [ i ] [ 0 ] != mat [ i ] [ j ] ) :
				return " Yes "
	return " No "
def nonZeroXor ( mat , N , M ) :
	res = 0
	for i in range ( N ) :
		res = res ^ mat [ i ] [ 0 ]
	if ( res != 0 ) :
		return " Yes "
	else :
		return checkRearrangements ( mat , N , M )
if __name__ == " _ _ main _ _ " :
	mat = [ [ 1 , 1 , 2 ] , [ 2 , 2 , 2 ] , [ 3 , 3 , 3 ] ]
	N = len ( mat )
	M = len ( mat [ 0 ] )
	print ( nonZeroXor ( mat , N , M ) )