Five persons A, B, C, D and E are seated in a circular arrangement. If each of them is given a hat of one of the three colours red, blue and green, then the number of ways of distributing the hats such that the persons seated in adjacent seats get different coloured hats is ____. [2019]
(30)
5 persons A, B, C, D and E are seated in circular arrangement.
Let A be given red hat, then there will be two cases.
Case I: B and E have same coloured hat blue/green. Say B and E have blue hat.
Then C and D can have either red and green or green and red i.e. 2 ways.

Similarly if B & E have green hat, there will be 2 ways for C & D.
Hence there are 2 + 2 = 4 ways.
Case II: B and E have different coloured hats blue and green or green and blue.

Let B has blue and E has green.
If C has green then D can have red or blue.
If C has red then D can have only blue.
∴ three ways.
Similarly 3 ways will be there when B has green and E has blue.
∴ there are 3 + 3 = 6 ways.
On combining the two cases, there will be 4 + 6 = 10 ways.
When similar discussion is repeated with A as blue and green hat, we get 10 ways for each.
Therefore, in all, there will be 10 + 10 + 10 = 30 ways.