Riddle: The Devil and Colored Hats
100 people find themselves at the gates of hell. The devil tells them that they'll have a chance to go to heaven instead, but first they'll have to play a game.
The devil is going to line them all up in a straight queue, each person facing the back of the next person in line. The order of people in this line will be randomly chosen when the game starts.
He is then going to put a red or blue hat on each person. Each hat can be red or blue at random. Nobody knows the color their hat will be before the game starts.
Each person will be able to see the hat of everyone in front of them, but won't be able to see the hats of anyone behind them. Everyone can hear everyone else.
The devil will then then ask each person the color of their hat, starting at the back of the line and moving forward. Each person must just say "red" or "blue", without any extra intonation. People cannot communicate at all beyond merely saying the word "red" or "blue". If a person correctly says the color of their own hat, then they will be sent to heaven;; if they get the color wrong they stay in hell.
Before the game starts, the people are allowed to come up with a strategy to save as many people as possible. One man proposes that every other person says the color of the hat of the person in front of them, and then the people in between repeat that color to save themselves. "That will save a guaranteed 50 people, and will probably save around 75," he says.
"No," a woman says. "I've got a plan that is guaranteed to save 99 of us, maybe all of us."
What is the woman's plan?