The sultan has a collection of three different colored hats- green, red and blue. He wants to test the wiseness of his Wise Couselors, he tells them that they will have to stand in a row, where everyone can see the hats of the counselors ahead of him, but none of the counselors behind him. He shows them his collection of red, blue and green hats- he has more than enough of each to allow any possible combination. He explains to them that they will each have to say the color hat that will be placed upon their heads and will only allow at most one mistake.

He lets them confer for a bit, then has them blindfolded, arranged in a row, hatted, un-blindfolded, and waits. The counselors call their own hat color, one by one, starting from the back. Only the first caller is wrong. They found a strategy that will always work. How can they do this?

Assume that there are 3, 4 or 5 Wise Counsellors that make up the group.

Next, the sultan gets a lot of yellow hats to add to his collection. Will the counselors still be able to pass the same test if there are 4 colors of hats?