# 2016 AIME II Problems/Problem 12

## Problem

The figure below shows a ring made of six small sections which you are to paint on a wall. You have four paint colors available and you will paint each of the six sections a solid color. Find the number of ways you can choose to paint the sections if no two adjacent sections can be painted with the same color.

$[asy] draw(Circle((0,0), 4)); draw(Circle((0,0), 3)); draw((0,4)--(0,3)); draw((0,-4)--(0,-3)); draw((-2.598, 1.5)--(-3.4641, 2)); draw((-2.598, -1.5)--(-3.4641, -2)); draw((2.598, -1.5)--(3.4641, -2)); draw((2.598, 1.5)--(3.4641, 2)); [/asy]$

## Solution 1

Choose a section to start coloring. Assume, WLOG, that this section is color $1$. We proceed coloring clockwise around the ring. Let $f(n,C)$ be the number of ways to color the first $n$ sections (proceeding clockwise) such that the last section has color $C$. In general (except for when we complete the coloring), we see that $$f(n,C_i)=\sum_{j\ne i} f(n-1,C_j),$$ i.e., $f(n,C_i)$ is equal to the number of colorings of $n-1$ sections that end in any color other than $C_i$. Using this, we can compute the values of $f(n,C)$ in the following table.

$\begin{tabular}{c|c|c|c|c } \multicolumn{1}{c}{}&\multicolumn{4}{c}{$$C$$}\\ $$n$$&1 & 2 & 3& 4 \\ \hline 1& 1 & 0 & 0 & 0\\ 2 & 0 & 1 & 1 & 1 \\ 3& 3 & 2 & 2 & 2 \\ 4 & 6 & 7 & 7 & 7 \\ 5 & 21 & 20 & 20 & 20\\ 6& 0& 61 & 61 & 61\\ \end{tabular}$

Note that $f(6, 1)=0$ because then $2$ adjacent sections are both color $1$. We multiply this by $4$ to account for the fact that the initial section can be any color. Thus the desired answer is $(61+61+61) \cdot 4 = \boxed{732}$.

## Solution 2

We use complementary counting. There are $4^6$ total colorings of the ring without restriction. To count the complement, we wish to count the number of colorings in which at least one set of adjacent sections are the same color. There are six possible sets of adjacent sections that could be the same color (think of these as borders). Call these $B_1,B_2,\dots,B_6$. Let $\mathcal{A}_1, \mathcal{A}_2,\dots,\mathcal{A}_6$ be the sets of colorings of the ring where the sections on both sides of $B_1,B_2,\dots,B_6$ are the same color. We wish to determine $|\mathcal{A}_1\cup\mathcal{A}_2\cup\cdots\cup\mathcal{A}_6|$. Note that all of these cases are symmetric, and in general, $|\mathcal{A}_i|=4^5$. There are $6$ such sets $\mathcal{A}_i$. Also, $|\mathcal{A}_i\cup\mathcal{A}_j|=4^4$, because we can only change colors at borders, so if we have two borders along which we cannot change colors, then there are four borders along which we have a choice of color. There are $\binom{6}{2}$ such pairs $\mathcal{A}_i\cup\mathcal{A}_j$. Similarly, $|\mathcal{A}_i\cup \mathcal{A}_j\cup \mathcal{A}_k|=4^3$, with $\binom{6}{3}$ such triples, and we see that the pattern will continue for 4-tuples and 5-tuples. For 6-tuples, however, these cases occur when there are no changes of color along the borders, i.e., each section has the same color. Clearly, there are four such possibilities.

Therefore, by PIE, $$|\mathcal{A}_1\cup\mathcal{A}_2\cup\cdots\cup\mathcal{A}_6|=\binom{6}{1}\cdot 4^5-\binom{6}{2}\cdot 4^4+\binom{6}{3}\cdot 4^3-\binom{6}{4}\cdot 4^2+\binom{6}{5}\cdot 4^1-4.$$ We wish to find the complement of this, or $$4^6-\left(\binom{6}{1}\cdot 4^5-\binom{6}{2}\cdot 4^4+\binom{6}{3}\cdot 4^3-\binom{6}{4}\cdot 4^2+\binom{6}{5}\cdot 4^1-4\right).$$ By the Binomial Theorem, this is $(4-1)^6+3=\boxed{732}$.

## Solution 3

We use generating functions. Suppose that the colors are $0,1,2,3$. Then as we proceed around a valid coloring of the ring in the clockwise direction, we know that between two adjacent sections with colors $s_i$ and $s_{i+1}$, there exists a number $d_i\in\{1,2,3\}$ such that $s_{i+1}\equiv s_i+d_i\pmod{4}$. Therefore, we can represent each border between sections by the generating function $(x+x^2+x^3)$, where $x,x^2,x^3$ correspond to increasing the color number by $1,2,3\pmod4$, respectively. Thus the generating function that represents going through all six borders is $A(x)=(x+x^2+x^3)^6$, where the coefficient of $x^n$ represents the total number of colorings where the color numbers are increased by a total of $n$ as we proceed around the ring. But if we go through all six borders, we must return to the original section, which is already colored. Therefore, we wish to find the sum of the coefficients of $x^n$ in $A(x)$ with $n\equiv 0\pmod4$.

Now we note that if $P(x)=x^n$, then $$P(x)+P(ix)+P(-x)+P(-ix)=\begin{cases}4x^n&\text{if } n\equiv0\pmod{4}\\0&\text{otherwise}.\end{cases}$$ Therefore, the sum of the coefficients of $A(x)$ with powers congruent to $0\pmod 4$ is $$\frac{A(1)+A(i)+A(-1)+A(-i)}{4}=\frac{3^6+(-1)^6+(-1)^6+(-1)^6}{4}=\frac{732}{4}.$$ We multiply this by $4$ to account for the initial choice of color, so the answer is $\boxed{732}$.

## Solution 4

Let $f(n)$ be the number of valid ways to color a ring with $n$ sections (which we call an $n$-ring), so the answer is given by $f(6)$. For $n=2$, we compute $f(n)=4\cdot3=12$. For $n \ge 3$, we can count the number of valid colorings as follows: choose one of the sections arbitrarily, which we may color in $4$ ways. Moving clockwise around the ring, there are $3$ ways to color each of the $n-1$ other sections. Therefore, we have $4 \cdot 3^{n-1}$ colorings of an $n$-ring.

However, note that the first and last sections could be the same color under this method. To count these invalid colorings, we see that by "merging" the first and last sections into one, we get a valid coloring of an $(n-1)$-ring. That is, there are $f(n-1)$ colorings of an $n$-ring in which the first and last sections have the same color. Thus, $f(n) = 4 \cdot 3^{n-1} - f(n-1)$ for all $n \ge 3$.

To compute the requested value $f(6)$, we repeatedly apply this formula: \begin{align*} f(6)&=4\cdot3^5-f(5)\\&=4\cdot3^5-4\cdot3^4+f(4)\\&=4\cdot3^5-4\cdot3^4+4\cdot3^3-f(3)\\&=4\cdot3^5-4\cdot3^4+4\cdot3^3-4\cdot3^2+f(2)\\&=4(3^5-3^4+3^3-3^2+3)\\&=4\cdot3\cdot\frac{3^5+1}{3+1}\\&=\boxed{732}.\end{align*} (Solution by MSTang.)

## Solution 5

Label the sections 1, 2, 3, 4, 5, 6 clockwise. We do casework on the colours of sections 1, 3, 5.

Case 1: the colours of the three sections are the same. In this case, each of sections 2, 4, 6 can be one of 3 colours, so this case yields $4 \times 3^3 = 108$ ways.

Case 2: two of sections 1, 3, 5 are the same colour. Note that there are 3 ways for which two of the three sections have the same colour, and $4 \times 3 = 12$ ways to determine their colours. After this, the section between the two with the same colour can be one of 3 colours and the other two can be one of 2 colours. This case yields $3 \times (4 \times 3) \times (3 \times 2 \times 2) = 432$ ways.

Case 3: all three sections of 1, 3, 5 are of different colours. Clearly there are $4 \times 3 \times 2 = 24$ choices for which three colours to use, and there are 2 ways to choose the colours of each of sections 2, 4, 6. Thus, this case gives $4 \times 3 \times 2 \times 2^3 = 192$ ways.

In total, there are $108 + 432 + 192 = \boxed{732}$ valid colourings.

## Solution 6

We will take a recursive approach to this problem. We can start by writing out the number of colorings for a circle with $1, 2,$ and $3$ compartments, which are $4, 12,$ and $24.$ Now we will try to find a recursive formula, $C(n)$, for a circle with an arbitrary number of compartments $n.$ We will do this by focusing on the $n-1$ section in the circle. This section can either be the same color as the first compartment, or it can be a different color as the first compartment. We will focus on each case separately.

Case 1:

If they are the same color, we can say there are $C(n-2)$ to fill the first $n-1$ compartments. The $nth$ compartment must be different from the first and second to last compartments, which are the same color. Hence this case adds $3*C(n-2)$ to our recursive formula.

Case 2:

If they are different colors, we can say that there are $C(n-1)$ to fill the first $n-1$ compartments, and for the the $nth$ compartment, there are $2$ ways to color it because the $n-1$ and $1$ compartments are different colors. Hence this case adds $2*C(n-1).$

So our recursive formula, $C(n)$, is $3*C(n-2) + 2*C(n-1).$ Using the initial values we calculated, we can evaluate this recursive formula up to $n=6.$ When $n=6,$ we get $\boxed{732}$ valid colorings.

Solution by NeeNeeMath