Recursive digit length
Substitution Patterns
A code string starts with A. At each step replace A with AB and B with A, simultaneously. After 17 replacement steps, what is the length of the string? Submit one integer.
Learning goal: Relate replacement counts to Fibonacci numbers.
Look for the underlying structure rather than guessing the next number. Submit only the final integer; you can open hints below as needed.
Check your answer without signing in. Sign in to save your progress.
Hints
Hint 1
A contributes 2 symbols and B contributes 1.
Hint 2
Count the numbers of A and B separately.
Hint 3
Their counts follow a two-term recurrence.
Common mistake to avoid
Assuming the first visible step stays constant without testing the full pattern.
How to approach this problem
Track the two letter counts separately. Under simultaneous replacement, the new A count is old A plus old B, and the new B count is old A.
Worked example with different values
Starting with A, the first three replacements produce AB, ABA, ABAAB, with lengths 2,3,5.
Apply the same reasoning to the challenge. This example is a separate practice problem.
Learn the technique: Sequence patterns: differences, recurrences and interleaving