0

Edit An explanation of why this question is completely different to the one that it has been associated with is given in comments, to the accepted answer.


I am trying to count the number of $n\times n$ matrices, where every entry is a lowercase alphabet, such that every row and column contains at least one "$a$".

I successfully found it for $N=2$, but I failed for $N = 3$.

Here is what I have done:

For a $3\times3$ matrix to satisfy this condition, we should have at least 3 A's, that too in particular locations. (i.e. 6 different ways of placing 3 A's)

So, with 3 a's, we will have $6\cdot (25^6)$

With 4 a's we will have $6\cdot \binom 61 \cdot(25^5)$

With 5 a's we will have $6\cdot \binom 62 \cdot(25^4)$ and so on.. this way.

But the answer seems incorrect. Can someone point out the mistake I did?

Thank you in prior

kumarp
  • 13

2 Answers2

2

With 4 a's we will have $6\cdot \binom61 \cdot(25^5)$

This is not correct. It excludes some matrices where no 3 a's satisfy the conditions.

\begin{matrix}a&a&?\\?&?&a\\?&?&a\end{matrix}

With 5 a's we will have $6\cdot \binom62 \cdot(25^4)$

This is also incorrect. Some matrices are excluded:

\begin{matrix}a&?&?\\a&?&?\\a&a&a\end{matrix}

while others are counted twice:

\begin{matrix}a&\color{blue}a&?&&\color{blue}a&a&?\\\color{blue}a&a&?&=&a&\color{blue}a&?\\?&?&a&&?&?&a\end{matrix}

Daniel Mathias
  • 5,415
  • 1
  • 12
  • 21
0

You could use the inclusion-exclusion principle, to get the number of ways of placing $m$ A's in the $n\times n$ grid, with at least one A on each row and each column. That is, you take all configurations of A's, then remove those configurations with no A's on each column and each row, then put back the ones you have double counted and so on: $$\sum_{s=1}^n\sum_{t=1}^n (-1)^{s+t}{n \choose s}{n\choose t}{(n-s)(n-t)\choose m}$$

Here ${n \choose s}$ is the number of sets of $s$ columns you could pick, ${n \choose t}$ is the number of sets of $t$ rows you could pick, and ${(n-s)(n-t)\choose m}$ is the number of ways of placing $m$ A's in the grid, with none on any of those $s$ rows, or $t$ columns.

Thus if we take your example of $n=3,\, m=4$, we get:\begin{eqnarray*}&\,\,&{9 \choose 4}-{3\choose 1}{3\choose 0}{6\choose 4}-{3\choose 0}{3\choose 1}{6\choose 4} +{3\choose 1}{3\choose 1}{4\choose 4}\\\\&=&126\qquad-3\times 15\qquad\quad-3\times 15\qquad\quad+9\times 1\\&=&45\end{eqnarray*}

This is different to your answer of $6\cdot{6\choose1}=36$, so that method is as you say wrong.

tkf
  • 11,563
  • See this question termed in equivalent terms of $0,1$ entries and its answer. – Jean Marie Nov 21 '21 at 08:38
  • @JeanMarie That answer gives the total number of $(0,1)$- matrices with at least one $1$ on each row and column. This question is asking how many such matrices there are with a given total number of $1$'s. The OP wanted to know why his formula for this was wrong, and DanielMathias gave an excellent explanation of this (+1). I then gave the correct formula. – tkf Nov 21 '21 at 09:36
  • I don't understand where in the title and/or the text is given this restriction "given total number of 1's". – Jean Marie Nov 21 '21 at 09:43
  • @JeanMarie In the text the OP does the calculation (wrongly) for total number of $1$'s equal to $3,4,5$, and asks for the mistake. In the title, the question being asked is equivalent to the value of a polynomial with the coefficients coming from these values, evaluated at $25$ (see OP's question). – tkf Nov 21 '21 at 09:50
  • I see. Thanks for your answer. – Jean Marie Nov 21 '21 at 09:57