\(n\) mathematicians with numbered party hats gather around in a circle... It is a matter of life or death!

I am excited to tell you that I *just* released the alpha version of my “Pydont's” book, a book that compiles all my “Pydon't” articles. You can get the book at leanpub: leanpub.com/pydonts.

### Foreword

I was challenged to solve this problem by Roger Hui, who wrote about it in an article[[1]][roger-article] a couple of years ago.

### Problem statement

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.

If you need any clarification whatsoever, feel free to ask in the comment section below.

### Solution

You can read the solution here to compare with your own solution.

If you liked this article and would like to support the mathspp project, then you may want to buy me a slice of pizza 🍕.