# Magic Hats Puzzle

Five people are stranded on an island.

A wizard comes and places a magic hat on some of their heads.

At least one of them now has such a hat.

Each hat can be seen by everyone but the wearer.

To remove the hat, those (and only those who have a hat) must dunk themselves underwater at exactly midnight.

The people cannot communicate until after the hats are removed.

They all want to remove the magic hats as soon as possible.

**How long does it take the people to remove the hats?**

**Solution:**

It will take N days to remove N hats.

*On the first day*, anyone seeing a hat will not know if they have one too.

Anyone seeing no hat on any head will know it must be on his head and remove on the first night.

*On the second day*, only the two with hats will see one hat on the rest, and they will know to remove them at midnight.

*On the N’th day*, N people will see N-1 hats and know they have a hat.