A group of cave gnomes, while in a dark cave, have their foreheads painted red or blue. They cannot see the color of their own foreheads, or anything else while they are in the cave. The gnomes are asked to exit the cave one by one and automatically sort themselves by color without communicating in any way after they leave the cave (verbal or non-verbal).
1. How did they do this?
The best way to achieve the solution is to have the gnomes form a line when they exit the cave. The order of the first two gnomes is irrelevant because they must stand next to each other regardless of their color. It is the third and then each sequential gnome that will be responsible for sorting. As the third gnome emerges from the cave, the colors of the previous two gnomes will be in one of the following possible combinations: rr, bb, or rb or br. If the first two gnomes are the same color, it wouldn't matter which gnome the third gnome decides to stand next to because they would be sorted