[Math] Number of colourings for which the vertices of a square can be coloured by three different colours such that adjacent vertices get different colours.

coloringcombinatorics

The vertices $A,B,C,D$ of a square $ABCD$ are to be coloured with one of three colours red, blue, or green such that adjacent vertices get different colours. What is the number of such colourings?

It seem that if $A$ is red coloured then none of $B$ or $D$ can be coloured by red one, so there are two options blue or green.Then if one of $B$ or $D$ is coloured with blue then $C$ can't be coloured with blue (same as for green one). Then we can colour $A$ by 3 ways (I mean we can colour $A$ by one of three colours) then $B$ by 2 ways again $C$ by two ways and lastly $D$ by also $2$ ways. So the nunber of such colourings must be $3×2×2×2=24$ ways. Is my way of approach is correct and also my answer? Please help me to solve this. Thanking you.

Best Answer

Without loss of generality, let $A$ be red. Then $B$ and $D$ can be independently coloured blue or green. If they are different (two ways), $C$ must be red. If they are the same (two ways), $C$ can be either red or the colour that $B$ and $D$ are not.

Similar reasoning applies if $A$ is blue or green. Thus there are $3(2\cdot1+2\cdot2)=18$ ways, not 24 as you calculated.

A generalised problem, counting the colourings of a square with $n$ colours, is given by OEIS A091940.

Related Question