\(n\) mathematicians with numbered party hats gather around in a circle... It is a matter of life or death!
I was challenged to solve this problem by Roger Hui, who wrote about it in an article[][roger-article] a couple of years ago.
Assume \(n\) mathematicians are in a circle, each mathematician with a hat in its head and facing the other \(n-1\) mathematicians. Each hat will be given a number from \(0\) to \(n-1\) and every mathematician will be able to see the numbers on the hats of all the other mathematicians. Of course no one will be able to see/know its own number. (In case you haven't understood yet, numbers can show up repeated.)
After some time, all mathematicians will write down, at the same time, a guess for the number on their own hat. If there is at least one person guessing it right, everyone lives. If no one guesses correctly, everyone dies!
Your task is to find out what is the strategy that the mathematicians must employ so that they are sure to live through this ordeal. The mathematicians can discuss the strategy before receiving the numbers but after that they must remain silent and won't be able to communicate with each other.
Give it some thought...
If you need any clarification whatsoever, feel free to ask in the comment section below.
You can read the solution here to compare with your own solution.