A wicked sorcerer felt enmity towards elf and thus he chooses four among the rest of the elf's and concealed them. The elves are concealed in the ground in a manner that apart from their head the rest of their body was underneath the ground. The elf's are unable to move their body and can only see in that direction that they are facing. All the elf's are concealed underground in such a way that they form a straight line and among those four elf's that are concealed underground one of the elf is detached form the other three elf's via wall. The entire elf's are in the same direction. The elf that is the furthest can only see the heads of its friends in front and a wall. The elf that is second last can only see one head of his friend and a wall. The second elf can only view the wall. The elf can see nothing.
The sorcerer understands the situation and tells the elf's that he has placed hats over their heads. Among the hats places two hat are blue and the other two are red. Among all the four elfs one of the elf has to guess that which colour hat is he wearing. If the elf answers correctly then he shall be set free or else he will have to dig beneath the ground till the very last.
Solution:
f the last elf is taking some time to answer the question then it shall mean that the elf's before him are all wearing distinct coloured hats. However sufficient time shall be given to the last elf to give the answer.
If he views the similar coloured hats in front of him , he shall quickly tell the answer