Forget about what you see. The problem is solved by eliminating the possibilities, one each hour.
At 12:00, you can eliminate four blue, one red, since the person with the red hat would have left the room.
At 13:00, you eliminate three blue, two red, because two people with red hats would have left the room: each knows he has a red hat, since the other person with a red hat didn't leave an hour ago.
And so forth. By the last hour, the only possibility left is all red hats, and every leaves at once.
|