share
MathematicsAll possible combinations of letters numbers up to length of 8 including duplicates.
[0] [1] MonteCristo
[2020-05-20 02:11:38]
[ combinatorics algorithms ]
[ https://math.stackexchange.com/questions/3683070/all-possible-combinations-of-letters-numbers-up-to-length-of-8-including-duplica ]

Given length of N, and given set of length of chars how many combinations I could make if I include duplicates letters in the string? I am looking for a formula.

e.g.

str = `ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789&%*^)"!`
N = 8

I could make

aaaaaaaa
aaaaaaaA
aaaaaaAA
aaaaaAAA
aaaaAAAA
aaaAAAAA
aaAAAAAA
aAAAAAAA
AAAAAAAA
aaaaaaa!
aaaaaa!!
aaaaa!!!
aaaAA!!!

....

What would be the total?

[0] [2020-05-20 02:39:28] Alain Remillard [ACCEPTED]

In your example, you have 59 characters, so you have 59 choices for the first element of the string, 59 choices for the second element of the string, etc. The number of possible strings is $$59\times59\times59\times59\times59\times59\times59\times59=59^8$$ More generaly, if you have $k$ letters and want to make string of length $N$, with repetitions, then you have $k^N$ possibilities.


1