Math Hats Puzzle

The Puzzle:

Math Hats

A scientist gathered four math students. They were then lined up so that each one could see the one in front of them but not behind them. Each had a hat placed on their head.

So the student in the back could see the hats of the three students in front, but the student in front could not see any hats.

"There is a red hat, a white hat, a blue hat, and a hat that is a duplicate of one of those colors," the scientist said.

Starting with the one in the back, each student was asked what color hat they were wearing. They all gave the correct answer!

What was the arrangement of the hats that made this possible?

Do you have the answer? Check against our solution!