Gnomes with hats  logic puzzle
Four smart gnomes are standing in line with all faces pointed in the
same direction. They all carry a hat, but they do not know their color. They only know that there are two red and two green hats. The first gnome stands behind a wall and does not see the others. The second gnome is able to see the hats of the third and the fourth.
The third only sees the hat of the fourth, and the fourth gnome does not see any hat at all.
The gnomes would like to know which hat they wear without checking their own. When a gnome has figured out which hat he carries, he will immediately tell the others. Suppose that the first gnome wears a red hat, the second a green one, the third a red one and the fourth a green one. Which gnome will be the first to figure out? 
Explanation
If the third and the fourth gnome would wear the same color, then the
second gnome could at once conclude which hat he carries. Since
this is not the current case, the second gnome does not know which hat
he carries. He will not say anything.
Therefore the third gnome can conclude that he necessarily should wear
the color opposite to the gnome in front of him. The third gnome is therefore the first to figure out.
