1

How many different ways are there to color the objects $a_1 , a_2 , ... , a_n$ ($n > 3$) using 3 colors if every color must be used at least once?

I thought it was $3^n - 6$ to account for the 6 cases that you have to disregard (all the same color, all two colors).

user127778
  • 233
  • 6
  • 17

2 Answers2

1

There are two interpretations: (i) The $n$ objects are distinct and (ii) They are identical.

(i) Let the colours be $A,B,C$. A colouring can be viewed as a function from the set $\{a_1,a_2,\dots,a_n\}$ to the set $\{A,B,C\}$. There are $3^n$ such functions.

However, some ,do not use all the colours: There are $2^n$ that do not use $A$, $2^n$ that do not use $B$, and $2^n$ that do not use $C$.

However, $2^n+2^n+2^n$ does not count correctly the forbidden colourings. For in the first $2^n$, the colourings that use neither $A$ nor $B$ are counted. They are also counted in the second $2^n$. The colourings that use neither $A$ nor $C$ are counted in the first $2^n$ and the third. And the colourings that use neither $B$ nor $C$ are also double-counted. So the number of forbidden colourings is $3\cdot 2^n$ minus the number of monochromatic colourings, which is $3$. There are $3\cdot 2^n-3$ forbidden colourings.

Thus the number of colourings in which every colour is used at least once is $3^n -3\cdot 2^n+3$.

(ii) Line up the $n$ identical objects. There are $n-1$ "gaps" between consecutive objects. Choose $2$ of these gaps to put a separator into, colour everything up to the first separator $A$, colour the objects between the two separators $B$, and the rest $C$. There are just as many allowed colourings of the identical objects as there are ways to insert separators. There are $\binom{n-1}{2}$ such ways.

Remark: The calculation for distinct objects used the Principle of Inclusion/Exclusion. The calculation for identical objects used the technique of Stars and Bars.

André Nicolas
  • 507,029
0

A colouring can be seen as a $n$-lettered string created from the three letters $r$, $g$, $b$ (red, green, blue) containing at least one $r$, one $g$ and and one $b$. The correspondent exponential generating function is thus

$$f(x)=\left(x^1+\frac{1}{2!} x^2 + \frac{1}{3!} x^3 + \ldots \right)^3 $$

and so the answer to this problem is the coefficient of $\frac{x^n}{n!}$ in $f(x)$ (why?). Now,

$$f(x)=(e^x-1)^3=3e^x-3e^{2x}+e^{3x}+1,$$

making the answer more or less evident; $3-3(2^n)+3^n=3^n-3(2^n)+3$.