DECEMBER'S PUZZLE: ARRANGING SOLDIERS IN A ROW
A commander decides to discipline his platoon after they misbehaved and also check their logic. He blindfolds their eyes and places hats on their heads. Some hats have a circle on the front of the hat, and some have a square. He arranges the soldiers in a column in front of the door of a room and gives them these orders:

  1. Enter the room one by one.
  2. Remove your blindfold after you enter the room.
  3. Don't remove your hat or in any way check what the sign on your hat is.
  4. Arrange yourselves in a row facing the door, with all soldiers with a circle on their hats on the left and all soldiers with a square on their hats on the right.
  5. Don't communicate with each other verbally or by any other means; rely solely on your sight and logic to form a row in compliance with these instructions (all circles to the left and all squares to the right).

Assume you're one of the soldiers who entered the room. You've removed your blindfold, and you're facing none, one, or more soldiers in front of you.You don't know what sign is on your hat, but you can see the signs on the hats of the soldiers already aligned in the row in front of you. What logic should you follow to comply with your commander's instructions?

WANT MORE T-SQL PUZZLES?


Look for Catch That Bug! and the solution to the November Logical Puzzle on Itzik's Puzzled by T-SQL blog at http://www.sqlmag.com/blog/index.cfm?action=blogindex&departmentid=1016