My uncle has told this riddle to many of the students and lecturers at the university where he works and he says nobody gets the right answer when they first hear it. However, once people start modelling the problem in the real world nearly everyone gets it almost immediately. Sure enough, when my cousin and I first heard the riddle it seemed impossible but within seconds of using bits of napkin to represent the dwarfs the answer seemed obvious. He mentioned that similar examples of self-ordering sets show up in biology, chemistry, and physics as well as Wizard’s caves.
A wizard has a load of dwarfs kept in a dark cave next to a beach. Each dwarf wears a hat, some hats are blue, some hats are red, but the cave is dark so the dwarfs don’t know the color of their hat.
One day the wizard decides he wants the dwarfs lined up on the beach with red hats on one side and blue hats on the other. He gives the dwarfs a single instruction then lets them walk out onto the beach one by one. Once every dwarf has left the cave they are correctly separated into coloured groups.
The dwarfs can’t speak to each other as the Wizard previously removed their tongues, and they can’t perform any kind of non-verbal communication.
What instruction did the Wizard give the dwarfs?