human
Median of Bitwise XOR of all submatrices starting from the top left corner | Function to find the median of bitwise XOR of all the submatrix whose topmost leftmost corner is ( 0 , 0 ).
dp [ i ] [ j ] : Stores the bitwise XOR of submatrix having top left corner at ( 0 , 0 ) and bottom right corner at ( i , j ).
Stores count of submatrix.
Base Case.
Base Case.
Fill dp using tabulation.
Fill dp [ i ] [ j ].
Driver code"
How can the above be solved in Python?
 Can you provide a code to median of Bitwise XOR of all submatrices starting from the top left corner and the other steps required?
assistant
#Here is code to median of Bitwise XOR of all submatrices starting from the top left corner and the other steps required.
 def findMedXOR ( mat , N , M ) :
	dp = [ [ 0 for i in range ( M ) ] for j in range ( N ) ] ;
	med = [ 0 ] * ( N * M ) ;
	dp [ 0 ] [ 0 ] = mat [ 0 ] [ 0 ] ;
	med [ 0 ] = dp [ 0 ] [ 0 ] ;
	len = 1 ;
	for i in range ( 1 , N ) :
		dp [ i ] [ 0 ] = dp [ i - 1 ] [ 0 ] ^ mat [ i ] [ 0 ] ;
		med [ len ] = dp [ i ] [ 0 ] ;
		len += 1 ;
	for i in range ( 1 , M ) :
		dp [ 0 ] [ i ] = dp [ 0 ] [ i - 1 ] ^ mat [ 0 ] [ i ] ;
		med [ len ] = dp [ 0 ] [ i ] ;
		len += 1
	for i in range ( 1 , N ) :
		for j in range ( 1 , M ) :
			dp [ i ] [ j ] = dp [ i - 1 ] [ j ] ^ dp [ i ] [ j - 1 ] ^ dp [ i - 1 ] [ j - 1 ] ^ mat [ i ] [ j ] ;
			med [ len ] = dp [ i ] [ j ] ;
			len += 1
	med . sort ( ) ;
	if ( len % 2 == 0 ) :
		return ( med [ ( len // 2 ) ] + med [ ( len // 2 ) - 1 ] ) / 2.0 ;
	return med [ len // 2 ] ;
if __name__ == ' _ _ main _ _ ' :
	mat = [ [ 1 , 2 ] , [ 2 , 3 ] ] ;
	N = len ( mat [ 0 ] ) ;
	M = 2 ;
	print ( findMedXOR ( mat , N , M ) ) ;