A prison warden offers his inmates a game for their freedom. He will secretly write a number on each of their foreheads, with no two foreheads having the same number. The inmates get to look around, seeing every other inmates' forehead, but not their own. They then go into separate rooms, and each place either a white or black hat on their own head. When they return, the prisoners are lined up in order of forehead number. They win if their hat colors now alternate white/black.
Once the game begins, the prisoners may not communicate, but beforehand, they may agree on a strategy. How can they guarantee victory?
This puzzle has a logical solution, there is no need for lateral thinking.
Added remarks: The numbers aren't necessarily integers, or positive, or interrelated at all (except they are all different). The numbers are the wardens choices, while the hat colors are the prisoners' choice. I got this from Rustan Leino's puzzle page.