AMC 10 · 2015 · #22

Grade 9 countingpattern
recursive-sequencemodular-arithmeticchinese-remainder-theorem pattern-recognitionidentify-subproblems ↑ Prerequisites: recursive-sequencemodular-arithmetic
📏 Long solution 💡 4 insights
Problem
A long string of two symbols may never repeat one symbol four times in a row. Find the count's remainder.

Pick an answer.

(A)
0
(B)
4
(C)
6
(D)
8
(E)
10
How to solve
Strategy Identify Subproblems

Tool #7 (Identify Subproblems) is the engine: a legal string ends in a block of 1, 2, or 3 identical letters, and chopping that block off leaves a shorter legal string, which turns one huge count into three smaller counts of the same kind. Tool #16 (Change Focus) first replaces 'count everything' with 'count only the strings ending in A', which the A⇔ B symmetry makes exactly half the total. Tool #9 (Solve an Easier Related Problem) trades the impossible question 'what is S(2015)' for the small one 'what is its remainder', and pins down exactly how much precision that needs. Tool #11 (Work Backwards) runs the recurrence in reverse to pin down a legal index-0 starting value, so the later index arithmetic lines up. Tool #5 (Look for a Pattern) reduces every term modulo 2 and modulo 3, where the sequence repeats after 4 and 13 terms. Tool #3 (Eliminate Possibilities) then sweeps the six residues mod 6 and keeps the only survivor.

1STEP 1

Split by the last letter

Symmetry makes the two endings equal.

S(n)=A(n)+B(n), and the A⇔ B swap gives A(n)=B(n), so S(n)=2A(n)
2STEP 2

Peel off the final block

Peeling the last block gives a recursion.

A(n)=B(n-1)+B(n-2)+B(n-3) for n ≥ 4
3STEP 3

Turn it into one sequence

It closes into one sequence.

A(n)=A(n-1)+A(n-2)+A(n-3) (n ≥ 4)
4STEP 4

Fix the starting values

The starting values are set by hand.

A(0)=1, A(1)=1, A(2)=2, A(3)=4, A(4)=7, A(5)=13, A(6)=24,…
5STEP 5

Decide what precision is needed

Only a small remainder needs following.

A=6q+r → S=2A=12q+2r → S≡ 2r (mod 12)
6STEP 6

Modulo 2: period 4

One modulus repeats every four terms.

A(n) mod 2: 1,1,0,0 | 1,1,0,0 |… and 2015=4 · 503+3, so A(2015)≡ A(3)≡ 0 (mod 2)
7STEP 7

Modulo 3: period 13

The other repeats every thirteen.

2015=13 · 155 → A(2015)≡ A(0)=1 (mod 3)
8STEP 8

Combine into one residue mod 6

Combining them pins one residue.

A(2015)≡ 0 (mod 2) and ≡ 1 (mod 3) → A(2015)≡ 4 (mod 6)
9STEP 9

Double it and read the remainder

Doubling gives 8, choice (D).

S(2015)≡ 2 · 4=8 (mod 12) → (D)
Answer
8
Test the machinery on lengths short enough to count directly. Every string of length 3 or less is legal, so S(1)=2, S(2)=4, S(3)=8. For length 4 there are 16 strings and exactly two illegal ones, AAAA and BBBB, giving S(4)=14; the recurrence agrees, since 8+4+2=14. Continuing gives S(5)=26, S(6)=48, S(7)=88, and a direct listing confirms these. The index arithmetic also checks out two ways: mod 6 the sequence A(n) repeats with period lcm(4,13)=52, and 2015=52 · 38+39, so A(2015)≡ A(39), which is indeed ≡ 4 (mod 6) — the same conclusion reached through the separate mod-2 and mod-3 cycles. Finally, S(n) is always even because legal strings pair off under the A⇔ B swap, so an even remainder was expected; every answer choice is even, so that alone does not decide it, and the sharper mod-6 work is what selects 8, choice (D).
💡Key takeaway

Count by how the string ends, turn that into a rule reaching back three steps, then track only the remainders — they run in a short cycle you can land on exactly.

  • Split by the last letter
  • Peel off the final block
  • Turn it into one sequence
  • Fix the starting values
  • Decide what precision is needed
  • Modulo 2: period 4
  • Modulo 3: period 13
  • Combine into one residue mod 6
  • Double it and read the remainder