text: We can arrive at this by considering some of the simpler cases.  Let's assume that the warden placed only 1 white hat on my head and 99 black hats on everyone else's head.  So at the time when the warden said start, I would look around and see 99 black hats.  Since there has to be at least one 1 hat, I would immediately announce that I had a white hat.  Everyone else would then know that they had black hats and would say so.\n\nNow consider the case where I have a white hat and someone else also has a white hat.  I would look and see 1 white hat.  If I had a black hat, that person would immediately announce that they had a white hat.  But that doesn't happen.  Instead they wait.  Now since neither of us was able to announce right away, we know that there must be 2 white hats.  So we both announce that we have white hats.\n\nYou can follow this pattern with 3 white hats, etc. but it requires that you have a plan in place for timing.  Let's say that everyone will wait ten seconds for every hat they see less of.  So if I see no white hats, I will immediately announce "WHITE" after 0 seconds.  Everyone else will follow with "BLACK" right after.  Similarly, if I saw 1 white hat, I would plan to say WHITE after 10 seconds.  If no one announced after 0 seconds, I would be correct.  Then everyone else would say "BLACK" after that.\n\nIt doesn't matter the number of hats or whether there are more or less of one color as long as we wait a discrete period of time to announce.  I chose periods of 10 seconds so that there wouldn't be a chance of mistakes.\n\nIf there are W white hats and B black hats, then:\nEveryone wearing a white hat will see W-1 white hats and B black hats.\nEveryone wearing a black hat will see B-1 black hats and W white hats.\n\nThere are 3 cases:\nIf W < B then all white hats will say 'White' at the same time (10(W-1) seconds), and everyone else knows they are wearing black. \nIf B < W then all black hats will say 'Black' at the same time (10(B-1) seconds), and everyone else knows they are wearing white. \nIf W = B then all prisoners will know their color at the same time. (10(B-1) seconds, or 10(W-1) seconds, they are equivalent). \n\nLet's take an example.  If there were 51 white hats and 49 black hats, and I was wearing a white hat.  Then I would plan to say "black" after 490 seconds.  However, the people in black hats would beat me to the punch saying "black" after 480 seconds.  Then I would say "white" along with all the rest of the prisoners wearing white hats.\n\nThe "hat puzzle" is described in detail at Wikipedia and I've included the link below.  I think the first answerer quoted from there but didn't include the reference.