Find the number of $4 \times 4$ matrices whose entries are each $2018$ or $—2018$ such that the sum of the entries in each row and in each column is $0$.
Now to get sum $0$ along a row we need two $2018$ and two $-2018$ and number of arrangement will be $\frac{4!}{2! 2!}$ but how adjust column while adjusting the rows or vice-versa? Could someone help me with this
Basically, we're after the number of $4 \times 4$ $(0,1)$-matrices $M=(m_{ij})$ with two $1$'s in each row and each column (and we can relabel the 0's to $2018$ and 1's to $-2018$).
There's 6 possible first rows, and they all complete to the same number of matrices, let's choose: $$ \begin{bmatrix} \color{blue} 1 & \color{blue} 1 & \color{blue} 0 & \color{blue} 0 \\ ? & ? & ? & ? \\ ? & ? & ? & ? \\ ? & ? & ? & ? \\ \end{bmatrix}. $$ The second row may be as shown in red below $$ \begin{bmatrix} \color{blue} 1 & \color{blue} 1 & \color{blue} 0 & \color{blue} 0 \\ \color{red} 1 & \color{red} 1 & \color{red} 0 & \color{red} 0 \\ 0 & 0 & 1 & 1 \\ 0 & 0 & 1 & 1 \\ \end{bmatrix} $$ which uniquely completes (indicated in black above). Or it may be as shown in red below $$ \begin{bmatrix} \color{blue} 1 & \color{blue} 1 & \color{blue} 0 & \color{blue} 0 \\ \color{red} 0 & \color{red} 0 & \color{red} 1 & \color{red} 1 \\ ? & ? & ? & ? \\ ? & ? & ? & ? \\ \end{bmatrix} $$ which has six completions (determined by the third row): $$ \begin{bmatrix} \color{blue} 1 & \color{blue} 1 & \color{blue} 0 & \color{blue} 0 \\ \color{red} 0 & \color{red} 0 & \color{red} 1 & \color{red} 1 \\ 1 & 1 & 0 & 0 \\ 0 & 0 & 1 & 1 \\ \end{bmatrix}, \begin{bmatrix} \color{blue} 1 & \color{blue} 1 & \color{blue} 0 & \color{blue} 0 \\ \color{red} 0 & \color{red} 0 & \color{red} 1 & \color{red} 1 \\ 1 & 0 & 1 & 0 \\ 0 & 1 & 0 & 1 \\ \end{bmatrix}, \begin{bmatrix} \color{blue} 1 & \color{blue} 1 & \color{blue} 0 & \color{blue} 0 \\ \color{red} 0 & \color{red} 0 & \color{red} 1 & \color{red} 1 \\ 1 & 0 & 0 & 1 \\ 0 & 1 & 1 & 0 \\ \end{bmatrix}, \begin{bmatrix} \color{blue} 1 & \color{blue} 1 & \color{blue} 0 & \color{blue} 0 \\ \color{red} 0 & \color{red} 0 & \color{red} 1 & \color{red} 1 \\ 0 & 1 & 1 & 0 \\ 1 & 0 & 0 & 1 \\ \end{bmatrix}, \begin{bmatrix} \color{blue} 1 & \color{blue} 1 & \color{blue} 0 & \color{blue} 0 \\ \color{red} 0 & \color{red} 0 & \color{red} 1 & \color{red} 1 \\ 0 & 1 & 0 & 1 \\ 1 & 0 & 1 & 0 \\ \end{bmatrix} \begin{bmatrix} \color{blue} 1 & \color{blue} 1 & \color{blue} 0 & \color{blue} 0 \\ \color{red} 0 & \color{red} 0 & \color{red} 1 & \color{red} 1 \\ 0 & 0 & 1 & 1 \\ 1 & 1 & 0 & 0 \\ \end{bmatrix}. $$ Or it may be one of those shown in red below $$ \begin{bmatrix} \color{blue} 1 & \color{blue} 1 & \color{blue} 0 & \color{blue} 0 \\ \color{red} 1 & \color{red} 0 & \color{red} 1 & \color{red} 0 \\ 0 & ? & ? & 1 \\ 0 & ? & ? & 1 \\ \end{bmatrix}, \begin{bmatrix} \color{blue} 1 & \color{blue} 1 & \color{blue} 0 & \color{blue} 0 \\ \color{red} 1 & \color{red} 0 & \color{red} 0 & \color{red} 1 \\ 0 & ? & 1 & ? \\ 0 & ? & 1 & ? \\ \end{bmatrix}, \begin{bmatrix} \color{blue} 1 & \color{blue} 1 & \color{blue} 0 & \color{blue} 0 \\ \color{red} 0 & \color{red} 1 & \color{red} 1 & \color{red} 0 \\ ? & 0 & ? & 1 \\ ? & 0 & ? & 1 \\ \end{bmatrix}, \begin{bmatrix} \color{blue} 1 & \color{blue} 1 & \color{blue} 0 & \color{blue} 0 \\ \color{red} 0 & \color{red} 1 & \color{red} 0 & \color{red} 1 \\ ? & 0 & 1 & ? \\ ? & 0 & 1 & ? \\ \end{bmatrix} $$ (where I indicate some forced 0's and 1's in black) each of which have two completions, such as $$ \begin{bmatrix} \color{blue} 1 & \color{blue} 1 & \color{blue} 0 & \color{blue} 0 \\ \color{red} 1 & \color{red} 0 & \color{red} 1 & \color{red} 0 \\ 0 & 1 & 0 & 1 \\ 0 & 0 & 1 & 1 \\ \end{bmatrix}, \text{ and } \begin{bmatrix} \color{blue} 1 & \color{blue} 1 & \color{blue} 0 & \color{blue} 0 \\ \color{red} 1 & \color{red} 0 & \color{red} 1 & \color{red} 0 \\ 0 & 0 & 1 & 1 \\ 0 & 1 & 0 & 1 \\ \end{bmatrix} $$ for the first example.
This gives $$ 6 \times (1+6+4 \times 2)=90 $$ matrices.
As a check, this is equal to the number of labeled $2$-regular subgraphs of $K_{4,4}$. Unlabeled, there's only $C_8$ and $C_4 \cup C_4$, to which we apply the Orbit-Stabilizer Theorem to enumerate the labeled cases, which gives: $$ \frac{4!^2}{8}+\frac{4!^2}{32}=90 $$ since the bipartition-preserving automorphism groups of $C_8$ and $C_4 \cup C_4$ have sizes $8$ and $32$, respectively.
As another check, we can generate them using the GAP code:
and it we input
Size(Q);we get90.