What’s the hat’s color

Three geniuses stand in a single-file line, one behind the other. Each can see only to the front, so the rear person can see the middle and the front, the middle person can see the front, and the genius in the front cannot see anyone. You have five hats. Two are white, and three are red. You blindfold the three geniuses, who are utterly truthful, and put a hat at random on the head of each. Then you hide the other two hats and remove the blindfolds. You then ask each genius to name the color of his hat which he cannot see. The rear one says “I don’t know.” The middle on says, “I don’t know.” Then the front one says, “I know.”

What color is the front genius’ hat?

The answer:
The man in the back can see two hats, but he doesn’t know what color his hat is. This means that the two hats are either red/red or red/white. If they were both white, he would know his was red.
The middle man is the key. From the back man, he can deduce the two options, red/red or red/white. He can see only one hat (the one front man’s hat). If that hat were white, he would know he was in the red/white combo, and would therefore know that his must be red. But he did not know.
From this, we can deduce that the front man’s hat is red.