Answer to the hat question;
First guy has to say he doesn?t know because the front two guys don?t have black hats on. Thereby he can?t tell what he is wearing either. He could see one red and one black, or one black and one red, or even two red hats, but he still can?t tell what hat he has on from his observations.
Second guy doesn?t see the front guy with a black hat on, or he would know for certain that he dosen?t have a black hat on because the guy behind him would have concluded his hat would then be red, by seeing two black hats in front of him. And that also would mean the second guy knows his hat would then be red if he sees a black hat on the front guy. So he sees only a red hat on the front guy. But that he also could have a red or black hat on his head and therefore can?t tell for certain what hat he has on.
The third guy thinking about the previous two statements, now knows his hat is red. There are on other color he could be wearing. If the first guy stated he is wearing a red hat, the third guy would know his hat would then be black as would the second guy. And if the second guy seen a black hat on the third guy then he would conclude his hat was red. But since neither of those two other guys could know for certain what hats they were wearing, the front guy knows for certain his hat is red.
WALA