logicAllan, Bertrand, and Cecil were caught stealing so the king sent them to the dungeon.
But the king decided to give them a chance.
He mad them stand in a line and put hats on their heads.
He told them that if they answer a riddle, they could go free.
Here is the riddle: "Each of you has a hat on your head. You do not know the color of the hat on your own head. If one of you can guess the color of the hat on your head, I will let you free. But before you answer you must keep standing in this line. You cannot turn around. Here are my only hints: there are only black and white hats. At least one hat is black. At least one hat is white."
Allan couldn't see any hats.
Bertrand could see Allan's hat but not his own.
Cecil could see Bertrand's hat and Allan's hat, but not his own.
After a minute nobody had solved the riddle. But then a short while later, one of them solved the riddle. Who was is and how did he know?

Bertrand knew the answer because Cecil didn't say anything after one minute. If Bertrand and Allan's hats were both the same color, then Cecil would know what color his hat was. But Cecil didn't know. So Bertrand knew that Allan's hat was a different color than his. Since Allan's hat was black, Betrand knew his hat was white.

logicYou have twelve balls, identical in every way except that one of them weighs slightly less or more than the balls.
You have a balance scale, and are allowed to do 3 weighings to determine which ball has the different weight, and whether the ball weighs more or less than the other balls.
What process would you use to weigh the balls in order to figure out which ball weighs a different amount, and whether it weighs more or less than the other balls?

Take eight balls, and put four on one side of the scale, and four on the other.
If the scale is balanced, that means the odd ball out is in the other 4 balls.
Let's call these 4 balls O1, O2, O3, and O4.
Take O1, O2, and O3 and put them on one side of the scale, and take 3 balls from the 8 "normal" balls that you originally weighed, and put them on the other side of the scale.
If the O1, O2, and O3 balls are heavier, that means the odd ball out is among these, and is heavier. Weigh O1 and O2 against each other. If one of them is heavier than the other, this is the odd ball out, and it is heavier. Otherwise, O3 is the odd ball out, and it is heavier.
If the O1, O2, and O3 balls are lighter, that means the odd ball out is among these, and is lighter. Weigh O1 and O2 against each other. If one of them is lighter than the other, this is the odd ball out, and it is lighter. Otherwise, O3 is the odd ball out, and it is lighter.
If these two sets of 3 balls weigh the same amount, then O4 is the odd ball out. Weight it against one of the "normal" balls from the first weighing. If O4 is heavier, then it is heavier, if it's lighter, then it's lighter.
If the scale isn't balanced, then the odd ball out is among these 8 balls.
Let's call the four balls on the side of the scale that was heavier H1, H2, H3, and H4 ("H" for "maybe heavier").
Let's call the four balls on the side of the scale that was lighter L1, L2, L3, and L4 ("L" for "maybe lighter").
Let's also call each ball from the 4 in the original weighing that we know aren't the odd balls out "Normal" balls.
So now weigh [H1, H2, L1] against [H3, L2, Normal].
-If the [H1, H2, L1] side is heavier (and thus the [H3, L2, Normal] side is lighter), then this means that either H1 or H2 is the odd ball out and is heavier, or L2 is the odd ball out and is lighter.
-So measure [H1, L2] against 2 of the "Normal" balls.
-If [H1, L2] are heavier, then H1 is the odd ball out, and is heavier.
-If [H1, L2] are lighter, then L2 is the odd ball out, and is lighter.
-If the scale is balanced, then H2 is the odd ball out, and is heavier.
-If the [H1, H2, L1] side is lighter (and thus the [H3, L2, Normal] side is heavier), then this means that either L1 is the odd ball out, and is lighter, or H3 is the odd ball out, and is heavier.
-So measure L1 and H3 against two "normal" balls.
-If the [L1, H3] side is lighter, then L1 is the odd ball out, and is lighter.
-Otherwise, if the [L1, H3] side is heavier, then H3 is the odd ball out, and is heavier.
If the [H1, H2, L1] side and the [H3, L2, Normal] side weigh the same, then we know that either H4 is the odd ball out, and is heavier, or one of L3 or L4 is the odd ball out, and is lighter.
So weight [H4, L3] against two of the "Normal" balls.
If the [H4, L3] side is heavier, then H4 is the odd ball out, and is heavier.
If the [H4, L3] side is lighter, then L3 is the odd ball out, and is lighter.
If the [H4, L3] side weighs the same as the [Normal, Normal] side, then L4 is the odd ball out, and is lighter.