Matrices and Combinatorics are a bad combination. Let $\scr A$ be the set of all $n\times n$ symmetric matrices all of whose entries are either $0$ or $1$ and such that if $n$ is even, $n^2/2$ of these entries are $1$ and $n^2/2$ of them are $0$, and if $n$ is odd then $(n^2+1)/2$ of these are $1$ and $(n^2-1)/2$ are $0$. 
I need to find:


*

*The number of matrices in $\scr A$.

*The number of matrices with non-zero determinant in $\scr A$. (and that also counts up indirectly the matrices with zero determinant.)


I have solved this problem for $n=3$ by explicitly writing the $12$ matrices with $6$ and $6$ matrices with zero and non-zero determinant.
Is there a general way to do this?
 A: I would go with an even matrix since this case is a little easier.  
When we choose $i$ $1's$ along the diagonal where $i$ is even(including 0). We would be left with $\left(\dfrac{n^2}{2}-i\right)$ $1's$ for non-diagonal elements. However, there are also $(n-i)$ $0's$ along the diagonal so there are total $\left(\dfrac{n^2}{2}-(n-i)\right)$ $0's$ left to be distributed in the non-diagonal elements.
We know that any matrix is symmetric, hence, $a_{ij}=a_{ji}$. Each element $a_{ij}$ is already fixed by the element $a_{ji}$. That means we can consider a pair $(a_{ij},a_{ji})$ which is always either filled by the pair $(1,1)$ or $(0,0)$. Number of these pairs to be filled is $\dfrac{\left(n^2-n\right)}{2}=\dfrac{n(n-1)}{2}$.
Number of pairs of $(1,1)$ is $\left(\dfrac{n^2}{4}-\dfrac{i}{2}\right)$ and number of pairs of $(0,0)$ is $\left(\dfrac{n^2}{4}-\dfrac{(n-i)}{2}\right)$, which are to be distributed among $\dfrac{n(n-1)}{2}$ possible pairs. 
Finally, ways of choosing $i$ $1's$ are $^nC_{i}$ 
Hence required combinations can be, 
$$\sum_{i=even} {^n}C_i \times \dfrac{\left(\frac{n(n-1)}{2}\right)!}{\left(\frac{n^2}{4}-\left(\frac{n-i}{2}\right)\right)!\times \left(\frac{n^2}{4}-\left(\frac{i}{2}\right)\right)!}$$
A: A matrix in $\mathcal A$ is determined by the $n$ entries in the diagonal and the $n(n-1)/2$ entries in its upper triangular part. Suppose now for example $n$ is even
If $i$ is the number of $1$s in the diagonal —which can be anything even from $0$ to $n$—  then the number of ones in the upper part is $n^2/2-i$. There are $\binom{n}{i}$ ways of putting the ones in the diagonal and $\binom{n(n-1)/1}{n^2/2-i}$ was of putting the ones in the upper part. It follows that the number of matrices in $\mathcal A$ is $$\sum_{\substack{i=0\\\text{$i$ even}}}^n\binom{n}{i}\binom{n(n-1)/2}{n^2/2-i}.$$ The odd case is entirely similar.
