Counting permutations of a string with repeating characters

In summary, the problem is asking for the number of five-letter strings of capital letters that have a letter repeated twice in a row. The solution involves selecting the first two letters, deciding where to place them in the string, and then selecting the remaining three letters while excluding repeats. This results in a total of 1,622,400 possible choices. However, to find the number of strings that do not meet the criteria, we can use the formula 26*25^4, which equals 72,656. Therefore, the final answer is 2,622,400 - 72,656 = 1,549,744.
  • #1
squelch
Gold Member
57
1
The problem statement:

How many five-letter strings of capital letters have a letter repeated twice in a row? For example, include ABCCA and AAABC and ABBCC but not ABCAD.

The attempt at a solution:

  • First, let's break down how we would perform the selection of a string that meets the question's criteria.
    • We select the first letter. There are 26 choices. This selection also triggers selection of the second letter, for which there is only one choice.
    • We then decide where in the five-position string to place these letters. There are four possible positions.
    • We then select for the other three letters. There are 26 possibilities for each letter, but we should exclude repeats. So the number of permutations for 26 letters to appear in three positions is P(26,3)=##\frac{26!}{(26-3)!}##
  • Then we combine the choices using the Product Rule.
    • [choices for first letter] * [choices for second letter] * [choices for position of first and second letter] * [permutations for remaining letters]
    • ##26*1*4*\frac{26!}{(26-3)!}=1622400##
  • We can then conclude that there are 1 622 400 such choices.
I have been having a bit of trouble with this topic, so I'm essentially looking for a sanity check on this solution. I get the sense that I may have missed some key point.
 
Physics news on Phys.org
  • #2
squelch said:
The problem statement:

How many five-letter strings of capital letters have a letter repeated twice in a row? For example, include ABCCA and AAABC and ABBCC but not ABCAD.

The attempt at a solution:

  • First, let's break down how we would perform the selection of a string that meets the question's criteria.
    • We select the first letter. There are 26 choices. This selection also triggers selection of the second letter, for which there is only one choice.
    • We then decide where in the five-position string to place these letters. There are four possible positions.
    • We then select for the other three letters. There are 26 possibilities for each letter, but we should exclude repeats. So the number of permutations for 26 letters to appear in three positions is P(26,3)=##\frac{26!}{(26-3)!}##
  • Then we combine the choices using the Product Rule.
    • [choices for first letter] * [choices for second letter] * [choices for position of first and second letter] * [permutations for remaining letters]
    • ##26*1*4*\frac{26!}{(26-3)!}=1622400##
  • We can then conclude that there are 1 622 400 such choices.
I have been having a bit of trouble with this topic, so I'm essentially looking for a sanity check on this solution. I get the sense that I may have missed some key point.
Not sure I follow you reasoning, especially the part about "We then select for the other three letters ..."

Hint: compute the number of 5 letter words that don't meet the question's criteria, meaning that no two adjacent letters are the same.
 
Last edited:
  • Like
Likes squelch
  • #3
Samy_A said:
Not sure I follow you reasoning, especially the part about "We then select for the other three letters."

Hint: compute the number of 5 letter words that don't meet the question's criteria, meaning that no two adjacent letters are equal.

Okay, so I know that the total number of strings is 265.

I consider a string where I'm selecting each character in turn to try to decide how many choices I get at each stage. If I want to construct a string where no two adjacent characters are the same, it seems that I could construct it in this way:
[ 26 choices for character 1] * [25 choices for character 2] * [25 choices for character 3] * [25 choices for character 4] * [25 choices for character 5]
... so 26*254 choices to exclude? That doesn't seem intuitive.

ninja edited to correct a horrible error
 
  • #4
squelch said:
Okay, so I know that the total number of strings is 265.

I consider a string where I'm selecting each character in turn to try to decide how many choices I get at each stage. If I want to construct a string where no two adjacent characters are the same, it seems that I could construct it in this way:
[ 26 choices for character 1] * [25 choices for character 2] * [26 choices for character 3] * [25 choices for character 4] * [26 choices for character 5]
... so 263*252 choices to exclude? That doesn't seem intuitive.
Do you really have 26 choices for character 3 (and character 5)?
 
  • #5
That was an awful error of mine that I thought I had corrected via edit fast enough, but alas, I did not.

Corrected:
[ 26 choices for character 1] * [25 choices for character 2] * [25 choices for character 3] * [25 choices for character 4] * [25 choices for character 5]
... so 26*25^4 choices to exclude?
 
  • #6
squelch said:
That was an awful error of mine that I thought I had corrected via edit fast enough, but alas, I did not.

Corrected:
[ 26 choices for character 1] * [25 choices for character 2] * [25 choices for character 3] * [25 choices for character 4] * [25 choices for character 5]
... so 26*25^4 choices to exclude?
Yes, that is the result I also have : 265-26*254.
 
  • Like
Likes squelch
  • #7
That was exceedingly helpful, thank you.
 

What is the definition of a permutation?

A permutation is the arrangement of a set of elements in a specific order.

How do you calculate the number of permutations for a given string with repeating characters?

To calculate the number of permutations for a string with repeating characters, you can use the formula n!/(n1!n2!...nk!), where n is the total number of characters and n1, n2,...nk are the number of times each character is repeated.

Can a string with repeating characters have the same number of permutations as a string without repeating characters?

No, a string with repeating characters will always have fewer permutations than a string without repeating characters. This is because the repeating characters limit the number of unique arrangements.

What is the significance of counting permutations in a string with repeating characters?

Counting permutations in a string with repeating characters is important in various fields, such as computer science, mathematics, and statistics. It can help in solving problems related to password cracking, data compression, and data encryption.

Is there a faster way to count permutations in a string with repeating characters?

Yes, there are various algorithms and methods that can be used to count permutations in a string with repeating characters. Some examples include using recursion, dynamic programming, or using the factorial formula with a loop. However, the most efficient method depends on the specific problem and string length.

Similar threads

  • Computing and Technology
2
Replies
52
Views
3K
  • Precalculus Mathematics Homework Help
2
Replies
36
Views
5K
  • Precalculus Mathematics Homework Help
Replies
8
Views
428
  • Calculus and Beyond Homework Help
Replies
2
Views
1K
  • Calculus and Beyond Homework Help
Replies
16
Views
2K
  • Precalculus Mathematics Homework Help
Replies
2
Views
3K
  • Programming and Computer Science
Replies
4
Views
2K
  • Calculus and Beyond Homework Help
Replies
2
Views
3K
  • Engineering and Comp Sci Homework Help
Replies
12
Views
3K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
2K
Back
Top