Permutations of string with restrictions

249 Views Asked by At

I want to get a total number of permutations of a $10$-character alphanumeric string. However, there are some restrictions. The first $5$ characters are only letters and the second $5$ characters are only numbers. I think this means that there should be $(26! \cdot 5) + (10! \cdot 5) = 2016457305633028177938144000$ string results. However no letter or number should be repeated more than $4$ times. In other words aaaab11112 is valid but aaaaa11111 is not, and so on and so forth. How would I account for this in my calculation?

3

There are 3 best solutions below

0
On

Well, i don't think your first computation is right. For the first part of the String you have $26$ possibilities on $5$ spots, so a total of $26^5$ options. From those you have to take out if you repeat $5$ times the same letter, but then that is taking into account by determining just the letter, so $26$ possibilities for a total of $26^5-26.$ Do the same for the second part of the String and use the product rule.

1
On

Hint: Subtract the cases from which you get $5$ of the same numbers and/or letters.

I'm only going to do this for the numbers, there are $10$ number characters, so there are $10^1=10$ ways of repeating a number character $5$ times.

1
On

You're calculation is incorrect without the restriction. There should be $$ 10^5 * 26^5 $$ possible strings without restrictions. Now you just have to remove the combinations that are excluded by the restriction. The first thing to do is to decide if the forbidden string violates the number or the letter restriction. If numbers, then it must be of the form 11111, 22222, ... 99999, 00000 (assuming more than four means strictly greater). There are 10 such sequences of letters and no restriction on letters so we get a total of $$ 10*26^5. $$ Do the same for letters and subtract these numbers from the total. Finally, at the end, note that we have subtracted too many since there are some sequences that violate both conditions. I'll leave that calculation for you.