Find an N x N grid whose xor of every row and column is equal | Function to find the n x n matrix that satisfies the given condition ; Initialize x to 0 ; Divide the n x n matrix into n / 4 matrices for each of the n / 4 rows where each matrix is of size 4 x 4 ; Print the generated matrix ; Driver code
def findGrid ( n ) : NEW_LINE INDENT arr = [ [ 0 for k in range ( n ) ] for l in range ( n ) ] NEW_LINE x = 0 NEW_LINE for i in range ( n // 4 ) : NEW_LINE INDENT for j in range ( n // 4 ) : NEW_LINE INDENT for k in range ( 4 ) : NEW_LINE INDENT for l in range ( 4 ) : NEW_LINE INDENT arr [ i * 4 + k ] [ j * 4 + l ] = x NEW_LINE x += 1 NEW_LINE DEDENT DEDENT DEDENT DEDENT for i in range ( n ) : NEW_LINE INDENT for j in range ( n ) : NEW_LINE INDENT print ( arr [ i ] [ j ] , end = " ▁ " ) NEW_LINE DEDENT print ( ) NEW_LINE DEDENT DEDENT n = 4 NEW_LINE findGrid ( n ) NEW_LINE