How many sequences of length N squared can be formed with N different values where each value is used exactly N times?

42 Views Asked by At

For instance, for N=2, the answer is 6 (e.g. aabb, abab abba baab baba bbaa). For N=3, the answer is 1680. I'm looking for the proper formula. Thanks

1

There are 1 best solutions below

0
On

The answer is $$\frac{(n^2)!}{(n!)^n}$$ This is the number of ways to divide a set of $n^2$ elements into $n$ subsets. It's the number of permutations of $n^2$ different elements, divided by the number of ways to permute the identical elements without changing the permutation.