Filling $4 \times 4$ matrix with Boolean values 
In how many ways can we fill a $4 \times 4$ matrix with only $0$'s and $1$'s such that all columns and rows contain an odd number of $1$'s?

I did it in the following way:
I can fill the $3 \times 3$ gray area in $2^9 = 512$ ways and then adjust the entries in the yellow regions such that each row and each column eventually contains an odd number of $1$'s. 

Then I observed the following:

Region A and B, the sum of bits in each of the regions must be odd. Therefore both yellow regions must be either odd or even at the same time. So, there is no conflict in the left bottom corner position. Finally, my answer is $512$. Is it correct?
I would like to know other counting technique for this particular problem. 
Thanks!
 A: I wrote a script in Swift that solves this question and prints the answer, and yes, the answer is $512$.
var matrix: [Bool] = [
    false,false,false,false,
    false,false,false,false,
    false,false,false,false,
    false,false,false,false
]

var shouldContinue: Bool = true
var numberOfValidMatrices: Int = 0

func changeMatrixNumbers() {
    for a in 0 ... 15 {
        if matrix[a] == false {
            matrix[a] = true
            if a > 0 {
                for b in 0 ... a - 1 {
                    matrix[b] = false
                }
            }
            break
        } else if a == 15 {
            shouldContinue = false
        }
    }
}

func isMatrixValid() -> Bool {
    // Rows
    for a in 0 ... 3 {
        var k: Bool = false
        for b in 0 ... 3{
            if matrix[4 * a + b] == true {
                k = k ? false : true
            }
        }
        if !k {
            return false
        }
    }
    // Columns
    for a in 0 ... 3 {
        var k: Bool = false
        for b in 0 ... 3 {
            if matrix[a + 4 * b] == true {
                k = k ? false : true
            }
        }
        if !k {
            return false
        }
    }
    return true
}

while shouldContinue {
    changeMatrixNumbers()
    if isMatrixValid() {
        numberOfValidMatrices += 1
    }
}

print(numberOfValidMatrices)

It can be run here.
A: I would solve this question as follows. Since every column must contain an odd number of $1$'s, the number of $1$'s is restricted to $4$, $6$, $8$, $10$ and $12$. We only need to distinguish three cases, since $4$ and $12$ and $6$ and $10$ are each other's inverse. Distinguishing three cases:


*

*Four $1$'s. Every column and row contains exactly one $1$, so the number of possible arrangements equals: $$4! = 24$$

*Six $1$'s. One column contains three $1$'s, the three others contain one $1$. Once the former $1$'s have been placed in the grid, either all three remaining $1$'s are placed in the empty row and columns, or one $1$ is placed in the empty row and columns, and two $1$'s are placed in one of the non-empty rows. The number of possible arrangements thus equals: $${4 \choose 1}{4 \choose 3}\bigg(1+{3 \choose 1}{3 \choose 2}\bigg) = 4 \cdot 4 \cdot (1 + 3 \cdot 3) = 160$$

*Eight $1$'s. Two columns contain three $1$'s and two columns contain one $1$. The six $1$'s must be distributed over all rows, otherwise it is impossible to have the three rows contain an odd number of $1$'s. Once these $1$'s have been placed in the grid, the remaining two $1$'s must be placed in the rows which contain two $1$'s. As such, the number of possible arrangements equals: $${4 \choose 2}{4 \choose 3}{3 \choose 2}{2 \choose 1} = 6 \cdot 4 \cdot 3 \cdot 2 = 144$$
The total number of arrangements thus equals:
$$24 + 160 + 144 + 160 + 24 = 512$$
