All the solutions to this I found online were either unnecessarily wordy or confusing due to formatting/syntactical issues. So, I'm adding mine which I will try to keep short and clear.
The Problem: You are given 12 balls. All of them are identical except one, which is either heavier or lighter than the rest. You are given a simple two-arm balance scale, which you can only use three times. How do you identify the odd ball, and whether it is lighter or heavier?
Solution: Divide balls into three equal groups (A,B,C) and number them (1-4) in each group.
Step 1. Weigh Group A against Group B:
- They balance => Odd ball is in Group C
Step 2. Weigh [C1, C2, C3] against any three normal balls (from groups A or B since they don't contain the odd ball).- They balance => C4 is odd
Step 3. Weigh C4 against any other ball to see if it is lighter or heavier. - [C1, C2, C3] heavier => One of [C1, C2, C3] is heavier
Step 3. Weigh C1 against C2. The heavier one is the odd ball, otherwise C3 is heavier. - Normal balls heavier => One of [C1, C2, C3] is lighter
Step 3. Weigh C1 against C2. The lighter one is the odd ball, otherwise C3 is lighter.
- They balance => C4 is odd
- Group A heavier => Either Group A contains a heavier ball or Group B has a lighter one
Step 2. Replace [B1, B2, B3] with three normal balls (let's say [C1,C2,C3] and swap A4 with B4. In other words, weigh [A1, A2, A3, B4] against [C1, C2, C3, A4].- They balance => One of the removed balls [B1, B2, B3] was lighter
Step 3. Weigh B1 against B2. The lighter one is the odd ball, otherwise B3 is lighter. - [A1, A2, A3, B4] heavier => (Odd ball hasn't moved.) One of [A1, A2, A3] is heavier
Step 3. Weigh A1 against A2. The heavier one is the odd ball, otherwise A3 is heavier. - [C1, C2, C3, A4] heavier => (The odd ball has switched sides.) Either A4 is heavier or B4 is lighter.
Step 3. Weighing one of them against a normal ball should tell you which is the case.
- They balance => One of the removed balls [B1, B2, B3] was lighter
- Group B heavier => This case is the same as Group A being heavier, just swap the A/B labels.