The king of Octopuses has servants who have six, seven or eight legs. The distinguishing characteristics of the servants is that the one with seven legs always lie but the one with either six or eight legs speak the truth always.

On a certain night, four servants meet and converse:
The black one says, 'We have 28 legs altogether.'
The green one says, 'We have 27 legs altogether.'
The yellow one says, 'We have 26 legs altogether.'
The red one says, 'We have 25 legs altogether.'

Can you identify the color of the servant who is speaking the truth?

Infosys Interview Puzzle

The green servant is telling the truth.

To prove it, let us first assume that one of them is telling the truth. It is obvious that three of the four servants are lying as they are disagreeing with each other.

Suppose if the black servant is telling the truth. In that case, the black one is having either 6 or 8 legs. And each of the other octopus is lying will then have 7 legs. In this case, the total number of legs will be 6 + 7 + 7 + 7 = 27 legs or 8 + 7 + 7 + 7 = 29 legs. But the black servant said that they have 28 legs all together. Thus he is lying.

Now follow the same logic with the remaining three servants as well assuming all of them truthful one by one. You will realize that only the Green octopus is telling the truth.