Apr 14, 2010

Weighing Piles of Coins

Source: Asked to me by Ankush Agarwal (Sophomore, CSE, IITB)

Problem: There are two kinds of coins, genuine and counterfeit. A genuine coin weighs X grams and a counterfeit coin weighs X+delta grams, where X is a positive integer and delta is a non-zero real number strictly between -5 and +5. You are presented with 13 piles of 4 coins each. All of the coins are genuine, except for one pile, in which all 4 coins are counterfeit. You are given a precise scale (say, a digital scale capable of displaying any real number). You are to determine three things: X, delta, and which pile contains the counterfeit coins. But you're only allowed to use the scale twice!

40 comments:

We are having 13 piles lets call them P1 ,P2 ... now take (2,2) (0,2) (2,0) (1,3) (3,1) (1,4) (4,1) (2,3) (3,2) (2,4) (4,2) (3,4) (4,3) coins from P1,P2,... (Note:(x,y) from Pj means x for the 1st measurement from Pj and y for the 2nd measurement from Pj.)It is clear that you are using 31 coins for each measurement , now it is also clear that you can use atmost 4 counterfeit coins in atmost 1 of the two measurements so there will be a measurement where the no. of counterfeit coins is 3 or less . Let the measured weight during the first attempt be m1 and the secon be m2 we then find p1,q1(nearest to m1) and p2,q2(nearest to m2) such that p1<=m1<=q1 , p2<=m2<=q2 such that p1,p2,q1,q2 are multiples of 31 for atleas one of the cases(WLG say the 1st measurement used less than 3 counterfeit coins) we will definetly have m1-p1 < 15 and q1-m1 > 15 (or the exact opp case) now we can conclude that X is p1/31 and now we find m1-p1 and m2-p1 say d1 and d2 depending on the ratio of d1 and d2 we can exactly identify which pile contais the counterfeit and also delta .

Just to reiterate,We are having 13 piles lets call them P1 ,P2 ...P13 and now take (2,2) (0,2) (2,0) (1,3) (3,1) (1,4) (4,1) (2,3) (3,2) (2,4) (4,2) (3,4) (4,3) coins from P1,P2,... P13. (Note:(x,y) from Pj means x for the 1st measurement from Pj and y for the 2nd measurement from Pj.) It is clear that you are using 31 coins for each measurement. It is also clear that we can use maximum 4 counterfeit coins in not more than 1 of the two measurements so there will be a measurement where the no. of counterfeit coins is 3 or less. Let the measured weight during the first attempt be m1 and the second be m2.

m1 = 31*X + xi*deltam2 = 31*X + yi*delta

if ith pile is counterfeit.

So, by floor and ceilings of m1 and m2, we get p1, q1 (multiples of 31 nearest to m1) and p2, q2 (multiples of 31 nearest to m2).

Since q1-p1=31, at least one of q1-m1 or m1-p1 has to be <= 15

Similarly, Since q2-p2=31, at least one of q2-m2 or m2-p2 has to be <= 15

Assuming the first is correct, we will have one value of X and Assuming the second is correct, we will have other value of X. Note that in some cases, both would be correct. But not all. Any suggestions? Am I missing something?

Let us take the first measurement as mentioned in my previous post if the measured value is say W1 and W1+K = 31*t or W1-K = 31*t for some integer t and 0 <= K < 11 then we can say that t is our actual weight we will then take the 2nd measurement and as we have distinct ratios we are done.Suppose we don't get such a number in the first measurement then we are sure that the faulty coin is not from {(2,2),(0,2),(2,0),(1,3),(1,4),(2,3),(2,4)} as if so then max error would have been 10 in 1st measurement and this is clearly not the case so the faulty coin is from {(3,1),(4,1),(3,2),(4,2),(3,4),(4,3)} so what we do now is for the 2nd measurement we take the above mentioned no. of coins from the above piles and 4 coins from the piles which we are sure that the faulty coin is not from , thee total number of coins is 41 so we can find all the 3 unknowns.

Weighing 1:Pick 4 from P1,P2,P3,P43 from P5,P6,P7,P82 from P9,1 from P10,P11,P12,P13

So we are using a total of 34 coins.Using 34 enables us to obtain y*d uniquely.There cannot be confusion between the pairs(20,-14),(19,-15)(18,-16)(17,-17) because at max, only 1 of these pairs can be a valid value for y*d.

So we can uniquely identify x.Let us discuss the worst case scenario when y*d is 4.In this case d can be 1,2,4.We can get different products for y2*d by selecting 0 from P11 from P2 and P102 from P3 and P113 from P4, P9 and P124 from P13

All other y*d have a maximum of 2 possiblities for d. For these cases we have to distinguish 8 sets for which we need 8 different products of y2*d, we have 10 totals for by selecting 0,1,2,3,4 from these sets, with two zeros and one other repeated product. So dropping one 0 and one of the repeated products we can always have 8 different products for y2*d.

Hope that I have not overlooked anything in my hurry to reach a solution :)

Not so sure about the proposed solution. It works in all cases, except for one specific situation.

When the delta is +/- 34/7, I believe a degeneracy occurs, making it impossible to tell the 4,3 pile from the 3,4 pile. In either case, attempts to solve the problem in this situation result in an ambiguity as to whether delta is positive or negative, the value of X (which could be one of two adjacent integer values), and which of these two piles contains the counterfeit coin.

I've worked out a small variation to Neeraj's solution, which gets around the problem I brought up earlier. If we make the following two changes to the groupings, I've determined that it will work for all values of delta up to +/- 6.5, and there may be a way to get even wider ranges to work.

Modify the groupings as follows:

4,33,4

2,44,23,3 : Change this to 4,4.

1,44,12,33,2

1,33,10,4 : Change this to 0,0|1. (see below)4,0

The key change here is the change of 0,4 to 0,0 or 0,1, depending on the result found in W1. First of all, changing the 3,3 to 4,4 ups the number of coins in W1 to 35. (This change may or may not be necessary, but I solved it with this change in place to maximize the number of coins being weighed, and it worked. I'll try it again later with 34 coins instead of 35 coins, to see what that gives.)

Using the coin in the second weighing of the 0,4 pile is conditional. If W1 modulo 35 equals zero, then the counterfeit coin must be in the 0,4 pile. (It was the only coin that wasn't weighed in W1, and given the ranges involved, W1 modulo 35 can only be 0 in the event that all coins on the scale are genuine.) In that case, weight one coin from this pile all by itself, and that will indicate the delta, where X is simply W1/35.

In the case where W1 modulo 35 is not equal to zero, the counterfeit pile must be in one of the piles on the scale. By eliminating the 0,4 pile from the second weighing, the number of coins being weighed in W2 is 31, and this makes the solution to the problem more unique.

Basically, W1 and W2 both must differ from 35*X and 31*X respectively by values that have distinct ratios with one another. These ratios can only be one of the following values: 0, 1/4, 1/3, 2/4, 2/3, 3/4, 4/4, 4/3, 3/2, 4/2, 3/1, and 4/1. Though there is a question of whether X is one of two adjacent values, in any of these cases, only one particular value will result in a ration from the following set. That value determines X, and it determines the ratio as well. From the ratio, it's possible to solve for delta and determine which pile is the counterfeit one. (Each of the values above corresponds to one particular pile.)

The key to this approach is using two different numbers of coins for the two weighings, which prevents certain degeneracies from occurring.

Pratik, you're right, it is getting messy, but there is actually a very elegant solution to this problem.

No, Mike's solution is not correct, not even for integral values of Delta. You can't determine Delta from ratios of the remainders modulo 35 and 31. Suppose Delta is -4 and you weigh 4 counterfeit coins in the first round and 3 in the second round. The remainders would both be 19. The ratio of the remainders would be 1:1 (or 4:4), but that doesn't mean that the number of counterfeits weighed in the first and second rounds is the same, so you can't determine the counterfeit pile.

Neerajkoul, please read your comment and repost if necessary. It seems that some (significant?) part of your post is lost because your {less,greater}-than signs are being interpreted as part of HTML tags.

I think I can vaguely guess what you are trying to say, but it's tough. For example, I find this part to be incomprehensible and I'm not sure how much is missing:If 0= 4

4 44 34 24 14 0

Five groups . weigh the second grouping from these balls. ( Means only 10 balls)

Had deleted my earlier posts because they were wrong solutions, rather they tried to solve a problem which wasn't there at all.. I hadn't read the problem clearly.. There was something mentioned about delta being strictly between -5 and 5( as in not including 5 and -5 ).. And all through i had assumed it to be between -5 and 5 ( as in inclusive of 5 and -5 )...

If Y=0, then 0 4 is the culprit. weigh one ball from the group and get the delta, as weight is X.

If 0 < Y < 15, then we know that delta is +ve and weight is X, get the second weighing and suppose it is W2.. Try fitting the variables, as in the no of balls from the group, in the weight eqns to know of the group and the delta.

If Y = 15, then it is the case of 4 balls, with +ve delta of 15/4 and weight X. No need of second weighing. ( 3*5 is 15 but delta can't be 5 , and also not 35+ 4*-5,as delta can't be -5 )

If Y = 20, then it is the case of 4 balls, with -ve delta of - 15/4 and weight (X+1). No need of second weighing. ( Same expln as above case )

If 20 < Y < 35, then it is the case of -ve delta. weight is X+1 and now get the second weighing and suppose it is W2.. Try fitting the variables, as in the no of balls from the group, in the weight eqns to know of the group and the delta.

Case of 15 < Y < 20 ( The monstrous case )======================================This just implies that it is the case of 4 ball groups which is counterfeit

3.75 < delta < 5or-5 < delta < -3.75

We know Weight can be X or X+1 depending on the delta. Weight has to be >= 4

4 44 34 24 14 0

Five groups . weigh the second grouping from these balls. ( Means only 10 balls)

suppose it is 10A+B

If B = 0, then group 4 0 is the culprit A = X weight is X and delta is +ve and is Y/4 A = X+1, weight is X+1 and delta is -ve and is -Y/4 Why so?. Can't B = +/- 10*SomeInt, Can be 10 or -10 , not +/- 20 ( because delta < 5 and > -5 ). And 10, a big No because +/- 10 = +/- 2.5 * 4 ( and +/- 2.5 is not in the delta rangesmentioned above ) +/- 10 = +/- 3.33 *3 ( and +/- 3.33 is not in the delta ranges mentioned above ) +/- 10 = +/- 5 * 2 ( refer to "strictly between 5 and -5" for delta in the prob definition )

Case of 15 < Y < 20 ( The monstrous case )======================================This just implies that it is the case of 4 ball groups which is counterfeit

3.75 < delta < 5or-5 < delta < -3.75

We know Weight can be X or X+1 depending on the delta. Weight has to be >= 4

4 44 34 24 14 0

Five groups . weigh the second grouping from these balls. ( Means only 10 balls)

suppose it is 10A+B

If B = 0, then group 4 0 is the culprit A = X weight is X and delta is +ve and is Y/4 A = X+1, weight is X+1 and delta is -ve and is -Y/4 Why so?. Can't B = +/- 10*SomeInt, Can be 10 or -10 , not +/- 20 ( because delta < 5 and > -5 ). And 10, a big No because +/- 10 = +/- 2.5 * 4 ( and +/- 2.5 is not in the delta rangesmentioned above ) +/- 10 = +/- 3.33 *3 ( and +/- 3.33 is not in the delta ranges mentioned above ) +/- 10 = +/- 5 * 2 ( refer to "strictly between 5 and -5" for delta in the prob definition )

Well i think was not clear enough in my explanation.. One of my friends still stood to ask questions about the soln..

Well here goes a bit more of the explanation..

Case of Y = 15 , that means No of balls is 4 ( as explained earlier) and that delta is +ve and of value 15/4.. I had wrongly written no second weighing is required.. We do need for getting the group..In this case g1 -> 4 4, g2 -> 4 3, g3 -> 4 2 , g4 -> 4 1 or g5 -> 4 0 is the group..Now take 4 balls from g1, 3 from g2, ...., and 0 from g5..Now take the second weighing.. Let it be W2.. Now we know X ( X of 35X+Y)and Y (15/4) both.. We just need to solve W2 = 10X+(15*4)*n for n to get to know of the group

Similar explanation goes for case of Y being 20.. ( Just that here weight is X+1 and delta is -ve and of value -15/4 )

For the case of say 0<Y<15 (delta is +ve) or 20<Y<35 ( delta is -ve) Now refer to the grouping we did4 3 3 44 4 4 2, etc..

These groupings are unique.. 4 3 is not repeated either in ratio or value.. ( We would have landed in a problem if we had taken say two or more groupings in ratio, e.g, 2 4 and 1 2 ( as 2/4 = 1/2 ), or 3 3 and 4 4 ( 3/3 = 4/ 4) ( Will explain later as to why )..

Now that we have got W1 and w2, and we know X..

So let's suppose W1 = 35X+d1W2 = 35X + d2

if W1 = W2, then 4 4 is the culprit group..else take group 2 ( 4 3) and solve as follows ..Take the value d1/4 and seeif W2 = 35X + 3*(d1/4) ( X is known from W1 itself).. If it equals, then 4 3 is the culprit group.. If it is not equal, then proceed to the next group , as in 3 4 and check..).. We won't have problems at a unique grouping because none of the groups are in the same ratio.. To explain it better, let's suppose that we had taken 2 4 and 1 2 as two of the groupings..Now suppose we got delta of 4 in the first weighing and 8 in the second weighing, then we will be at fix as 2*2 = 4 *1 = 4and 2*4 = 4 *2 = 8..

EASY case : if p1=p2 then counterfeit pile is 7th (with 4/4) and a1=a2=4. in next step take any coin from other piles and get value of x and delta.

else

calculate sum w=p1+p2=70x+ delta(a1+a2). now since |delta|<5 and (a1+a2)<= 7 hence |delta(a1+a2)| < 35 Hence nearest integer (w/70) = x now find y1=p1-35x=delta*a1 and y2=p2-35x=delta*a2 So y1/y2 = a1/a2 Since a1/a2 is different for all the 13 piles hence from this you know which pile the counterfeit coin belongs

Amazon.com Mathematics Bestsellers

Buy me Coffee / Beer via Paypal/BTC

Pages

Search This Blog

Follow by Email!

About Me

I am an early stage technology investor at Nexus Venture Partners. Prior to this, I was a 3x product entrepreneur. Prior to this, I worked as a private equity analyst at Blackstone and as a quant analyst at Morgan Stanley. I graduated from Department of Computer Science and Engineering of IIT Bombay. I enjoy Economics, Dramatics, Mathematics, Computer Science and Business.

Disclaimer

This is a personal blog. Any views or opinions represented in this blog are personal and belong solely to the blog owner and do not represent those of people, institutions or organizations that the owner may or may not be associated with in professional or personal capacity. Any views or opinions are not intended to malign any religion, ethnic group, club, organization, company, or individual.

All content provided on this blog is for informational purposes only. The owner of this blog makes no representations as to the accuracy or completeness of any information on this site or found by following any link on this site. The owner will not be liable for any errors or omissions in this information nor for the availability of this information. The owner will not be liable for any losses, injuries, or damages from the display or use of this information.