Take a test Sign in 中文
← Exercise 561 →
Search
Go to
{{searchResults.length}} {{searchResults.length === 1 ? 'result' : 'results'}} for “{{searchWords}}” No results found for “{{searchWords}}” × back to contents
Contents · by chapter
Basic Counting (147)
Balls in Boxes (6)
Probability (142)

Exercises and their solutions

Exercise 561
For each positive integer $n$, let $S(n)$ be the number of sequences of length $n$ consisting solely of the letters $A$ and $B$, with no more than four $A$s in a row and no more than four $B$s in a row. What is the remainder when $S(2016)$ is divided by $12$?
← Back to Problem 561
Solution
  1. A sequence is determined by its first letter ($2$ choices) and its run lengths, each $1$, $2$, $3$, or $4$. So $S(n)=2T(n)$, where $T(n)$ is the number of ways to write $n$ as an ordered sum of $1$s, $2$s, $3$s, and $4$s.
  2. With $T(0)=1$, $T(1)=1$, $T(2)=2$, $T(3)=4$, we have $T(n)=T(n-1)+T(n-2)+T(n-3)+T(n-4)$ (look at the last part). The first values are $T(1),\dots,T(8)=1,2,4,8,15,29,56,108$.
  3. We need $T(2016)\bmod 6$. Modulo $2$, the values $T(1),T(2),\dots$ are $1,0,0,0,1,\ 1,0,0,0,1,\dots$ with period $5$ (the $4$ previous values $1,0,0,0$ repeat). Since $2016\equiv1\pmod5$, $T(2016)\equiv T(1)=1\pmod2$.
  4. Modulo $3$, the values $T(1),\dots,T(26)$ are
    \[
    1,2,1,2,0,2,2,0,1,2,2,2,1,\ 1,0,1,0,2,0,0,2,1,0,0,0,1,
    \]
    and then $T(27),\dots,T(30)\equiv1,2,1,2$ again, so the period is $26$. Since $2016=26\cdot77+14$, $T(2016)\equiv T(14)\equiv1\pmod3$.
  5. So $T(2016)\equiv1\pmod6$ and $S(2016)=2T(2016)\equiv\boxed{2}\pmod{12}$.
Search Go to Prev      Next

Contact Us

Thanks! Your message has been sent.
By year