[Math] Calculate the number of ways to paint $5$ buildings with $4$ colours such that all $4$ colours must be used

combinatoricsnumber theorypermutations

A developer has recently completed a condominium project in a valley. There are blocks of buildings $A$, $B$, $C$, $D$ and $E$ as shown in the diagram below.
enter image description here

The developer has colours available to paint the buildings. Each block can only be painted using a single colour. Find the number of ways to paint all the blocks if all $4$ colours must be used.

My attempt: We have $5$ ways to choose $4$ buildings with $4$ different colours. Among the $4$ buildings, we have $4!$ ways to paint them using $4$ different colours.

So my answer is $120$. However, the answer given is $240$. What is my mistake?

Best Answer

You're on the right track. After choosing the four buildings with different colours, what about the fifth? It will be a repeated colour, and there are four colours to choose from. However, we will have overcounted by a factor of $2$, so the final answer will be $$120\cdot\frac42 = 240$$ To explain the overcounting, suppose that you first choose $A,B,C,D$ as the set of four buildings. Then $E$ is the same as one of them, say $A$. But then we will also later consider $E,B,C,D$ as the set of four, with $A$ the same as $E$.