Let π be the set of all ternary strings defined over the alphabet \(\{π, π,β¦
2025
Let π be the set of all ternary strings defined over the alphabet \(\{π, π, π\}\). Consider all strings inΒ \(S\) that contain at least one occurrence of two consecutive symbols, that is, βaaβ, βbbβ or βccβ. The number of such strings of length 5 that are possible is _______. (Answer in integer)
Attempted by 53 students.
Show answer & explanation
Correct answer: 195
Answer: 195
Total number of ternary strings of length 5: 3^5 = 243
Count the strings that have no two consecutive symbols equal (i.e., avoid "aa", "bb", "cc") and subtract from the total:
Choose the first symbol: 3 choices.
For each of the remaining 4 positions, you must pick a symbol different from the previous one: 2 choices each, giving 2^4 = 16.
So the number of strings with no consecutive equal symbols is 3 * 2^4 = 48.
Therefore the number of length-5 strings that contain at least one occurrence of two consecutive identical symbols is 243 - 48 = 195.