2026-03-26

Problem — 2026-03-26

Medium

Mediumcombinatorics

How many 55-letter strings using only AA and BB contain no three consecutive AA's?

Enter an integer

Show solution
Let ana_n be the count of valid nn-letter strings. A valid string can start with BB, ABAB, or AABAAB, each followed by a valid string. So an=an1+an2+an3a_n = a_{n-1} + a_{n-2} + a_{n-3}. With a1=2a_1 = 2, a2=4a_2 = 4, a3=7a_3 = 7: a4=7+4+2=13a_4 = 7+4+2 = 13, a5=13+7+4=24a_5 = 13+7+4 = 24.