Space Cadet... here is a solution for your ball-breaker *******************************************************
Label the balls 1 through 12.
Load the scales as shown: SIDE1: 1,2,3,4 SIDE2: 5,6,7,8
if(SIDE1 heavier than SIDE2) { Load the scales as shown: SIDE1: 1,2,5 SIDE2: 3,6,9
if(SIDE1 heavier than SIDE2) { Load the scales as shown: SIDE1: 1 SIDE2: 2
if(SIDE1 heavier than SIDE2) { // Ball 1 is the odd-ball, and is heavy } else if(SIDE2 heavier than SIDE1) { // Ball 2 is the odd-ball, and is heavy } else if(balanced) { // Ball 6 is the odd-ball, and is light } } else if(SIDE2 heavier than SIDE1) { Load the scales as shown: SIDE1: 3 SIDE2: 9
if(SIDE1 heavier than SIDE2) { // Ball 3 is the odd-ball, and is heavy } else if(SIDE2 heavier than SIDE1) { // Impossible, should never happen } else if(balanced) { // Ball 5 is the odd ball, and is light } } else if(balanced) { Load the scales as shown: SIDE1: 7 SIDE2: 8
if(SIDE1 heavier than SIDE2) { // Ball 8 is the odd-ball, and is light } else if(SIDE2 heavier than SIDE1) { // Ball 7 is the odd-ball, and is light } else if(balanced) { // Ball 4 is the odd-ball, and is heavy } } }
else if(SIDE2 heavier than SIDE1) { Load the scales as shown: SIDE1: 1,2,5 SIDE2: 3,6,9
if(SIDE1 heavier than SIDE2) { Load the scales as shown: SIDE1: 3 SIDE2: 9
if(SIDE1 heavier than SIDE2) { // Impossible, should never happen } else if(SIDE2 heavier than SIDE1) { // Ball 3 is the odd-ball, and is light } else if(balanced) { // Ball 5 is the odd ball, and is heavy } } else if(SIDE2 heavier than SIDE1) { Load the scales as shown: SIDE1: 1 SIDE2: 2
if(SIDE1 heavier than SIDE2) { // Ball 2 is the odd-ball, and is light } else if(SIDE2 heavier than SIDE1) { // Ball 1 is the odd-ball, and is light } else if(balanced) { // Ball 6 is the odd-ball, and is heavy } } else if(balanced) { Load the scales as shown: SIDE1: 7 SIDE2: 8
if(SIDE1 heavier than SIDE2) { // Ball 7 is the odd-ball, and is heavy } else if(SIDE2 heavier than SIDE1) { // Ball 8 is the odd-ball, and is heavy } else if(balanced) { // Ball 4 is the odd-ball, and is light } } }
else if(balanced) { Load the scales as shown: SIDE1: 9,10 SIDE2: 11,1
if(SIDE1 heavier than SIDE2) { Load the scales as shown: SIDE1: 9 SIDE2: 10
if(SIDE1 heavier than SIDE2) { // Ball 9 is the odd-ball, and is heavy } else if(SIDE2 heavier than SIDE1) { // Ball 10 is the odd-ball, and is heavy } else if(balanced) { // Ball 11 is the odd-ball, and is light } } else if(SIDE2 heavier than SIDE1) { Load the scales as shown: SIDE1: 9 SIDE2: 10
if(SIDE1 heavier than SIDE2) { // Ball 10 is the odd-ball, and is light } else if(SIDE2 heavier than SIDE1) { // Ball 9 is the odd-ball, and is light } else if(balanced) { // Ball 11 is the odd-ball, and is heavy } } else if(balanced) { Load the scales as shown: SIDE1: 12 SIDE2: 1
if(SIDE1 heavier than SIDE2) { // Ball 12 is the odd-ball, and is heavy } else if(SIDE2 heavier than SIDE1) { // Ball 12 is the odd-ball, and is light } else if(balanced) { // Should never happen } } } |