Let's assume I have 4 positions (let's give letters to those positions: m,n,l,p). Each position can be occupied by numbers from 0 up to N-1 with repetition allowed. For instance, let's assume N=3:
m n l p
0,0,0,0
0,0,0,1
0,0,0,2
0,0,1,0
0,0,1,1
0,0,1,2
0,0,2,0
0,0,2,1
0,0,2,2
0,1,0,0
. . .
. . .
. . .
2,2,2,2
I'd like to find a equation/formula where I can find the number of elements in each one of the following groups:
1)
m=n=l=p
2)
(m=n=l)!=p
(m=n=p)!=l
(m=l=p)!=n
(n=l=p)!=m
3)
(m=n)!=(l=p)
(m=l)!=(n=p)
(m=p)!=(n=l)
4)
(m=n)!=(l!=p)
(m=l)!=(p!=n)
(m=p)!=(l!=n)
(p=n)!=(m!=l)
(p=l)!=(m!=n)
(n=l)!=(p!=m)
5)
m!=n!=l!=p
Rather than doing the case $N=3$ we shall do $N=n$. When we use different letters in a configuration, they are understood to indicate different values.
The configuration $aaaa$ will occur with mutliplicity $1$ and there are $n$ of these.
The configuration $aaab$ will occur with mutliplicity $4$ and there are $n(n-1)$ of these.
The configuration $aabb$ will occur with mutliplicity $6$ and there are $n(n-1)/2$ of these.
The configuration $aabc$ will occur with mutliplicity $12$ and there are $n(n-1)(n-2)/2$ of these.
The configuration $abcd$ will occur with mutliplicity $24$ and there are $n(n-1)(n-2)(n-3)/24$ of these.
You will quickly verify that \begin{eqnarray*} 1 \times n + 4 \times n(n-1) +6 \times \frac{n(n-1)}{2} +12 \times \frac{n(n-1)(n-2)}{2} \\+ 24 \times \frac{n(n-1)(n-2)(n-3)}{24} =n^4 \end{eqnarray*} as expected.