Software Design
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreSoftware Design

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 18th, 2002, 06:15 AM
Sulik Sulik is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Posts: 10 Sulik User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Wink Little brain excercise.

Imagine that u have 8 balls, 7 of them have the same weight, and one of them is a little heavier.
U alse have a weighting device with two cups. U can place as many balls on one cup as u wish, and the device will show you which cup weights more.
The problem is to find the heavier ball using the minimum number of weighting procedures.
What will be your algorythm for that?

Reply With Quote
  #2  
Old November 18th, 2002, 12:26 PM
ScottBP ScottBP is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2000
Location: CA US
Posts: 62 ScottBP User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
How about put 4 balls in each cup, take the heavier set and split 2 balls in each, take the heavier and split 1 ball in each, 3 steps to get heaviest.

Scott
__________________
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Scott B. Pier
ScottBP@amalla.com
http://www.amalla.com

Reply With Quote
  #3  
Old November 18th, 2002, 06:09 PM
AlCapone's Avatar
AlCapone AlCapone is offline
Mobbing Gangster
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Sep 2001
Location: "Best City" 2002 and 2003- Melbourne, Australia
Posts: 4,913 AlCapone User rank is Sergeant (500 - 2000 Reputation Level)AlCapone User rank is Sergeant (500 - 2000 Reputation Level)AlCapone User rank is Sergeant (500 - 2000 Reputation Level)AlCapone User rank is Sergeant (500 - 2000 Reputation Level)AlCapone User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 5 h 36 m 31 sec
Reputation Power: 18
Send a message via ICQ to AlCapone Send a message via AIM to AlCapone Send a message via Yahoo to AlCapone
Quote:
Originally posted by ScottBP
How about put 4 balls in each cup, take the heavier set and split 2 balls in each, take the heavier and split 1 ball in each, 3 steps to get heaviest.

Scott

Nah. When you think about it, you can do better. What you do is you get 3 and 3 balls and put 'em on weights.
1) they are equal
&nbsp;&nbsp;&nbsp; You get last two balls, put them on weights and get the heaviest one
2) one part is heavier
&nbsp;&nbsp;&nbsp;You put 1 ball from those 3 on one plate and another on another
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;i) they are equal
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;3rd ball is heaviest
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ii) one of them is heavier, it's the heaviest

Heaviest ball in 2 measurements. Where can I collect my prize?
__________________
And you know I mean that.

Reply With Quote
  #4  
Old November 18th, 2002, 07:11 PM
ScottBP ScottBP is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2000
Location: CA US
Posts: 62 ScottBP User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
Very nice !!

.... But I wanted the prize

Reply With Quote
  #5  
Old November 19th, 2002, 01:31 AM
Sulik Sulik is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Posts: 10 Sulik User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Talking Well, u did not :))

yes, the second guy is right

Reply With Quote
  #6  
Old November 19th, 2002, 11:37 PM
Robo Robo is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2001
Posts: 29 Robo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
How many weights would you need if you DIDN'T know whether the special ball is lighter or heavier?

Reply With Quote
  #7  
Old November 20th, 2002, 12:00 AM
AlCapone's Avatar
AlCapone AlCapone is offline
Mobbing Gangster
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Sep 2001
Location: "Best City" 2002 and 2003- Melbourne, Australia
Posts: 4,913 AlCapone User rank is Sergeant (500 - 2000 Reputation Level)AlCapone User rank is Sergeant (500 - 2000 Reputation Level)AlCapone User rank is Sergeant (500 - 2000 Reputation Level)AlCapone User rank is Sergeant (500 - 2000 Reputation Level)AlCapone User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 5 h 36 m 31 sec
Reputation Power: 18
Send a message via ICQ to AlCapone Send a message via AIM to AlCapone Send a message via Yahoo to AlCapone
Quote:
Originally posted by Robo
How many weights would you need if you DIDN'T know whether the special ball is lighter or heavier?

erm... I'd say 5.

edit: there are 3 ways I can think of (4x4,3x3,2x2x2x2), but all of them need 5 measurements, what am I missing?

Last edited by AlCapone : November 20th, 2002 at 12:03 AM.

Reply With Quote
  #8  
Old November 27th, 2002, 08:18 PM
andy3109's Avatar
andy3109 andy3109 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Posts: 421 andy3109 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 h 46 m 21 sec
Reputation Power: 7
Send a message via AIM to andy3109
The same amount, 2. For the same reasoning of comparing weight.

Reply With Quote
  #9  
Old November 27th, 2002, 09:44 PM
AlCapone's Avatar
AlCapone AlCapone is offline
Mobbing Gangster
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Sep 2001
Location: "Best City" 2002 and 2003- Melbourne, Australia
Posts: 4,913 AlCapone User rank is Sergeant (500 - 2000 Reputation Level)AlCapone User rank is Sergeant (500 - 2000 Reputation Level)AlCapone User rank is Sergeant (500 - 2000 Reputation Level)AlCapone User rank is Sergeant (500 - 2000 Reputation Level)AlCapone User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 5 h 36 m 31 sec
Reputation Power: 18
Send a message via ICQ to AlCapone Send a message via AIM to AlCapone Send a message via Yahoo to AlCapone
Quote:
Originally posted by andy3109
The same amount, 2. For the same reasoning of comparing weight.

Wrong - you cannot do this in 2 steps because you don't know if the ball if heavier or lighter. So if you measure 3 and 3, and say one of them is heavier it doesn't mean 'special' ball is in there. So you have to do more measurements.

Reply With Quote
  #10  
Old November 27th, 2002, 11:02 PM
andy3109's Avatar
andy3109 andy3109 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Posts: 421 andy3109 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 h 46 m 21 sec
Reputation Power: 7
Send a message via AIM to andy3109
Yes, I misunderstood it at first. Now I know what you meen. hmm..my guess would be:

3 and 3, if same weight then calculate the weight of one cup/3. Put other two balls on and the number that comes closest to the cup weight/3 is the ball. That way would work with two steps if a little luck at hand.

if...

3 and 3, if not the same weight then take one out of each cup. If same weight then take the weight of one of the cups/2 is one of the remaining balls that was taken out. That is 3 steps. And so on and so on.

In conclusion for the equation to work everytime. Four is my guess.

Reply With Quote
  #11  
Old November 28th, 2002, 03:31 AM
AlCapone's Avatar
AlCapone AlCapone is offline
Mobbing Gangster
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Sep 2001
Location: "Best City" 2002 and 2003- Melbourne, Australia
Posts: 4,913 AlCapone User rank is Sergeant (500 - 2000 Reputation Level)AlCapone User rank is Sergeant (500 - 2000 Reputation Level)AlCapone User rank is Sergeant (500 - 2000 Reputation Level)AlCapone User rank is Sergeant (500 - 2000 Reputation Level)AlCapone User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 5 h 36 m 31 sec
Reputation Power: 18
Send a message via ICQ to AlCapone Send a message via AIM to AlCapone Send a message via Yahoo to AlCapone
And how, may I ask, are you going to calculate weight? All you got is balance - and the only thing they say is which group of balls is heavier/lighter. You cannot weight it and see how heavy they are.

Reply With Quote
  #12  
Old November 28th, 2002, 02:36 PM
andy3109's Avatar
andy3109 andy3109 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Posts: 421 andy3109 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 h 46 m 21 sec
Reputation Power: 7
Send a message via AIM to andy3109
Well. I misunderstood yet again. I thought it said a scale, not a balance. I am not going to attempt anymore because I know I'll miss another detail.
-andy

UPDATE: I am right. Read first post.

"U alse have a weighting device with two cups. "

Reply With Quote
  #13  
Old December 18th, 2002, 10:04 AM
Mincer's Avatar
Mincer Mincer is offline
.DOTTY
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Location: London
Posts: 206 Mincer User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 21 m 51 sec
Reputation Power: 6
Quote:
Originally posted by andy3109
UPDATE: I am right. Read first post.

"U alse have a weighting device with two cups. "


Update: It actually tells you that the device will tell you which cup weighs more, it makes no reference to being able to show specific weight measurements, therefor you cannot assume as such.

This is my take:

1) compare 3 and 3, this will tell you which set of three the odd ball is in.

2) compare 2 of the three, if they are equal, the third is the odd one. otherwise, if they are not the same it must be one of those two, but you do not know if one is lighter or heavier than the others so...

3) compare one of the two against any of the other 7 (as you have ascertained that these are all the same). If there is still a difference, then it is the one you kept, otherwise it is the other.

Reply With Quote
  #14  
Old December 19th, 2002, 07:23 PM
dcaillouet's Avatar
dcaillouet dcaillouet is offline
Big Endian
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: May 2001
Location: Fly-over country
Posts: 1,173 dcaillouet User rank is Sergeant (500 - 2000 Reputation Level)dcaillouet User rank is Sergeant (500 - 2000 Reputation Level)dcaillouet User rank is Sergeant (500 - 2000 Reputation Level)dcaillouet User rank is Sergeant (500 - 2000 Reputation Level)dcaillouet User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 16 h 29 m 5 sec
Reputation Power: 24
One additonal method for finding it in three measurements:

Break the balls into 4 groups of 2 (let's call them A, B, C, D)

1. Weigh A x B
2. Weigh A x C

From this you can derive the status of group D. The results would be analyzed as follows.

1. Balance 2. Balance = Odd ball in D
1. Balance 2. Unbalance = Odd ball in C
1. Unbalance 2. Balance = Odd ball in B
1. Unbalance 2. Unbalance = Odd ball in A

Once you know which pair has the odd ball after two measurements, an additional measurement against one of the six known standard balls will let you know which one is odd.

Reply With Quote
  #15  
Old December 19th, 2002, 11:11 PM
AlCapone's Avatar
AlCapone AlCapone is offline
Mobbing Gangster
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Sep 2001
Location: "Best City" 2002 and 2003- Melbourne, Australia
Posts: 4,913 AlCapone User rank is Sergeant (500 - 2000 Reputation Level)AlCapone User rank is Sergeant (500 - 2000 Reputation Level)AlCapone User rank is Sergeant (500 - 2000 Reputation Level)AlCapone User rank is Sergeant (500 - 2000 Reputation Level)AlCapone User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 5 h 36 m 31 sec
Reputation Power: 18
Send a message via ICQ to AlCapone Send a message via AIM to AlCapone Send a message via Yahoo to AlCapone
Mincer, that's what I did in my first post, but it doesn't work if you don't know whether the ball is heavier or lighter (hence group of 3 heavier or lighter).

dcaillouet, *clap*clap*. One thing I don't get though - I did the same thing 3 weeks ago (in my second post) and somehow I counted to 5 while doing that

Reply With Quote
Reply