SI
SI
discoversearch

We've detected that you're using an ad content blocking browser plug-in or feature. Ads provide a critical source of revenue to the continued operation of Silicon Investor.  We ask that you disable ad blocking while on Silicon Investor in the best interests of our community.  If you are not using an ad blocker but are still receiving this message, make sure your browser's tracking protection is set to the 'standard' level.
Pastimes : Brain Teasers. -- Ignore unavailable to you. Want to Upgrade?


To: space cadet who wrote (88)3/2/1998 5:20:00 AM
From: Mitch Blevins  Read Replies (1) | Respond to of 136
 
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
}
}
}