This is one of the hardest logic puzzles I have ever come across. Part of the reason for that is the mindset and type of skills required to solve it are completely alien to any formal training or life experiences I have had. To ensure you can enjoy it without spoiling it, the puzzle is described below but rather than writing out the answer in plain English I have included a Python script which solves the problem.

I don’t know the origin of this puzzle and I’ve searched the Internet to no avail. I can’t even find a copy of the puzzle text or any variation of it. I have an idea of where it came from, but that isn’t confirmed so if you know please open an issue and let me know!


The Wizards Hats:

10 wizards are being held captive by an evil and powerful witch. The evil witch is going to present them with a test, and if the wizards fail the test, the witch will kill them all.

The 10 wizards will be summoned to stand in a circle all facing inwards so that they can all see each other. The evil witch will conjure a hat to appear on the head of each wizard. Each of the 10 hats will be one of 10 possible colours chosen at random. Each wizard will be able to see the colour of the hats on the other 9 wizard’s heads, but each wizard won’t be able to see the colour of the hat on their own head.

The witch will ask each wizard one at a time what the colour of the hat on their own head is. If just one of the wizards can correctly guess the colour of the hat on their own head, all 10 wizards will be spared. If none of them can correctly guess their own hat colour they will all be killed.

Once the wizards have been summoned for the test, the wizards can no longer commnunicate amongst themselves, otherwise the witch will kill them. This means that what one wizards says when announcing their guess has no influence on the guess of any of the other wizards.

It is the night before the summoning, and the wizards have foreseen that this test will be presented to them in the morning by their captor. But the witch is too powerful, they can’t foresee the hat colours. They can discuss the night before a strategy which they can each use the following morning, to try and guess their own hat colour correctly. They must formulate a strategy which guarantees that at least one of them will guess their own hat colour correctly. What is the strategy they can use?


To be clear, given a list of 10 possible colours, the colour of the hat that will appear on each wizard’s head will be one of those 10 colours chosen at random. This means that each of the 10 wizards could have a different coloured hat on, or they could all be wearing the same colour, or any combination of the 10 possible colours. Exactly what the 10 colours are is irrelevant.

Each wizard can only see the other wizards because they are standing in an inward facing circle. This means that the only information they have available about their own hat colour is the colour of the other 9 hats they can see.

This is a maths/logic puzzle, it’s not based on a trick like each wizard winking the colour of another’s wizard hat to them in morse code, or each wizard coughing to shake their own hat down into their own field of vision.