Page 2 of 2
Posted: Thu Dec 22, 2005 11:25 am
by Num3
Shake the bag...
If the ball is light it will sink to the bottom.... if it's heavy it will surface above others...
Posted: Thu Dec 22, 2005 11:35 am
by srod
netmaestro wrote:Alas, the only prize on offer is "Biggest Cheapskate", which is yours (if you want it!) Again, good work.
Humbug!
Right, xmas is cancelled this year!

Posted: Fri Dec 23, 2005 11:16 pm
by Jan Vooijs
my 2 cents in just 5 minutes thinking, no paper used no computer, no internet aka NO google.
12 balls, divide in two sets of 6 balls (both sets on the scale = 1$). The one who goes UP has the ligthweight ball (1 of 6 balls).
next devide the 6 balls in two sets of 3 balls (both sets on the scale = 1$). The one set (of three balls) who goes UP has the ligthweight ball (1 of 3).
now we have 3 balls (oops odd).
next divide in three sets of ONE ball. Any two balls on the scale.
a) if even (balanced) the other ball NOT on the scale is the lightweight.
b) the one who goes UP is the leightweight ball
Total 3 times usage of the scale, so 3 bucks.
No messy fiddling with all kinds of colored balls or usage of calculators (joke)....
Posted: Fri Dec 23, 2005 11:21 pm
by netmaestro
That's pretty expensive as one complete use of the scales is wasted.
Here is some pseudocode I had kicking around:
Code: Select all
MARKINGS: U = UNCLASSIFIED
G = GOOD
H = POSSIBLY HEAVY
L = POSSIBLY LIGHT
MARK ALL BALLS 'U'
WEIGH 4U VS 4U LEAVING 4U
IF BALANCE
REMARK 8 BALLS 'G'
WEIGH 3U,1G VS 4G
IF BALANCE
REMARK 3 BALLS G
WEIGH IG VS 1U -> DONE
ELSE
IF 3U,1G ^
REMARK 3U 'L'
WEIGH 1L VS 1L LEAVING 1L -> DONE
ELSE
REMARK 3U 'H'
WEIGH 1H VS 1H LEAVING 1H -> DONE
ENDIF
ENDIF
ELSE
REMARK 4 BALLS 'G'
REMARK 4 BALLS 'H'
REMARK 4 BALLS 'L'
WEIGH 2H,2L VS 1H,3G LEAVING 1H,2L
IF BALANCE
REMARK 3H,2L 'G'
WEIGH 1L VS 1L LEAVING 1H -> DONE
ELSE
REMARK 1H,2L 'G'
IF 2H,2L ^
REMARK 2H 'G'
WEIGH 1L VS 1L LEAVING 1H -> DONE
ELSE
REMARK 2L,1H 'G'
WEIGH 1H VS 1H LEAVING 1L -> DONE
ENDIF
ENDIF
ENDIF
Posted: Fri Dec 23, 2005 11:34 pm
by srod
Jan Vooijs wrote:my 2 cents in just 5 minutes thinking, no paper used no computer, no internet aka NO google.
12 balls, divide in two sets of 6 balls (both sets on the scale = 1$). The one who goes UP has the ligthweight ball (1 of 6 balls).
As netmaestro pointed out, we are not told whether the odd one out is underweight or overweight, and as such, comparing 6 balls with 6 is a wasted use of the scales as all that tells you is that one of the balls does not weight the same as the remaining 11 !
Incidentally, what exactly would someone type into google anyhow? I shudder to think what would turn up (apart from the police) if I typed in 'balls' !
Try 5 cents next time!
Re: Balls question
Posted: Sat Dec 24, 2005 2:54 am
by Jan Vooijs
@NetMeastro,
Ooh crap you are right!! I presumed a lightweight ball!! My bad.
But that corrects itself after my second set of (light) balls they are equal so i know to look for a heavy ball in the other set of 6 balls. So 3 and 3 balls and three 1 balls if they are equal the heavy ball is the remaining one ball. Same principle. But yes 3 or 4 uses of the scale no more.
There is a error in your own code after the else statement of the second weighing.
you code:
Code: Select all
ELSE
REMARK 2L,1H 'G'
WEIGH 1H VS 1H LEAVING 1L -> DONE
ENDIF
the "LEAVING 1L" is wrong. There is NO 1L the "REMARK 2L,1H 'G'" got the 2 only L you have left, you only have the 2H to weigh to know which of both is the heavy one!!
So this is the correct code:
Code: Select all
ELSE
REMARK 2L, 1H 'G'
WEIGH 1H VS 1H -> DONE
ENDIF
You say the answer that Srod gives is correct but it USES allways 4 times to weigh??? Where he states "2nd comparison tells us whether one of ABC" is the 3rd time he is using the scale not the 2nd!! Than he continues to wheigh balls A&B makes it four times!!
-------------------
@Srod,
Looking on google for "balls problem" see the top two entries??? That was what I meant by looking on the internet aka google (and NO dirty pictures).[/code]
Posted: Sat Dec 24, 2005 3:02 am
by netmaestro
I should point out that in those days I wrote mainly in COBOL...
@srod: The cleverest problem solvers get a handle on it in under 15 minutes, and prove it in under an hour. You certainly fit into that group. Good work.
Posted: Sat Dec 24, 2005 3:20 am
by DoubleDutch
I should point out that in those days I wrote mainly in COBOL
Every have a competition to see who could get the most errors from a single PIC ?
Posted: Sat Dec 24, 2005 12:41 pm
by srod
You say the answer that Srod gives is correct but it USES allways 4 times to weigh??? Where he states "2nd comparison tells us whether one of ABC" is the 3rd time he is using the scale not the 2nd!! Than he continues to wheigh balls A&B makes it four times!!
You don't actually use the scales again, I'm simply referring back to the second comparison which provides quite a bit of info. I really don't think you've read this solution in full.