Post Go back to editing

KCC's Quizzes: Contaminated Pills

  1. Eight jars with hundreds of identical looking pills, although 7 jars have medicine pills of 1000 mg each, 1 jar has contaminated pills of 999 mg each. The contaminated pills are ever so slightly lighter than the medicine pills. You have a precise electronic scale (precision better than 1mg). With ONE (1) weighing, how can you detect the jar with the medicine pills?
  2. Same question as above but the situation is there could be multiple jars with contaminated pills. With ONE (1) weighing, how can you identify which jars (could be multiple) have contaminated pills?

Many thanks to Ralph Montforts, ADI Director, General Accounting for proposing this quiz!



Edit title
[edited by: emassa at 3:46 PM (GMT -5) on 18 Jan 2023]
Please share your answer to view other submitted answers
  • Hi,

    1. Number the jars from 1 to 8 and place N pills from the N-th jar on the scale using all jars. W is the measured weight in mg units. The serial number of the jar containing the 999 mg pills is 1000*(1+2+3+4+5+6+7+8)-W.
    2. Number the jars from 0 to 7 and place 2^N pills from the N-th jar on the scale using all jars. W is the measured weight in mg units. If the N-th bit in the binary representation of W-255*999 is 0, then the N-th jar contains 999 mg pills. Note, that other sets of 8 integer numbers can also be used if the sum of any subset is not in the set.

    ADI offers accurate enough ADCs to do the job for both cases using a precision load cell :-).

    Zoltan

  • Answer 1. You can take 1 pill from jar nr.1, 2 pills from jar nr. 2, 3 pills from jar nr.3 and so on and weigh all the 36 pills. The difference between 36g and the weighing result will give you the number of contaminated pills.

    Answer 2. Same mechanism as above, but you need to take "power of 2" number of pills: 1 from jar 0, 2 from jar 1, 4 from jar 2, 8 from jar 3 and so on. The difference between 255g and the weighing result will allow you to identify the jars with contaminated pills.  

  • Hi, not gonna give my (correct) answer, but interested in replies

  • 1) Label the jars 1-8. Pull out a number of pills from each jar equal to the jar number (eg, 3 pills from jar #3).  Weigh all the pulled pills.  The weight should be 36,000mg (36g) if all the pills were OK but the weight will be smaller due to the pills that are contaminated.  The amount of milligrams that the weight is below 36,000mg is the number of the jar that is contaminated (eg, if the weight is less than 36,000g by 4mg, then bottle #4 is the contaminated bottle.)

    2) I assume that each jar has at least 256 pills in them.  So, similar to number one, only this time take a number of pills equal to 2 to the exponent of the bottle number (eg, take 2^4 = 16 pills from jar #4).  Weigh all the pills and the weight reduction due to contaminated pills will be a number corresponding to the bottles that are contaminated.  You must look at the number in its binary form though (it will be an 8 bit number), so if the weight is short by 138mg, then its binary equivalent is 10001010 and therefore bottles 8, 4, and 2 are contaminated.)

    Brian Barrett

  • 1. Place one pill of jar #1, two pills of jar #2, three pills of jar #3 ... and 8 pills of jar #8 onto the scale.
        If the reading shows:
        xxxx2 mg, then jar #8 is the one with the contaminated pills
        xxxx3 mg, then jar #7 is the one with the contaminated pills
        .....
        xxxx9 mg, then jar #1 is the one with the contaminated pills

    2. Place one pill of jar #1, two pills of jar #2, four pills of jar #3 ... and 128 pills of jar #8 onto the scale.
        If all pills are not contaminated you will read 255'000 mg.
        If there are any contaminated pills, you will read "x" mg less than 255'000 mg
        Convert "x" to binary. Every "1" in the binary number indicates a jar with contaminated pills,
         the LSB corresponds to jar #1 ... the MSB corresponds to jar #8

  • Take one pill from jar 1, 2 pills from jar 2, 3 pills from jar 3.....and so on. And total pills will be 36 and weight of these will be 36000 mg. So if it weighs 35999 means jar one is contaminated and other are medicine pills, if it weighs 35998 means jar 2 is contaminated.... And so on. 

    Same will go for second one just contaminated one will be changed with medicine one. Here if it weighs 35965 means jar 1 contains medicine pills and 35966 jar 2 will contains..... And so on. 

  • Since the weighing of N pills will be 1mg shy of N grams per contaminated pill on the scale, to determine which jar is contaminated we just need to correlate different pill quantities with each jar, weigh them all collectively, and see how many mg below N grams the weighing is, which will point us to the correct jar.  E.g., number the jars 1 to 8 and weigh that many pills from each jar - a total of 36 pills.  The ideal weight would be 36 grams without contamination, but knowing 1 jar has contaminated pills the weighting will come up X mg short of 36 grams, and X will be the jar # with the contaminated pills.

    For the second weighing, we will need to use quantities of pills from each jar that would produce a unique weighing regardless of how many contaminated pill jars there may be.  The simplest way to do that is assigning binary weightings of the quantity of pills we weigh from each jar.  Again, numbering the jars 1 to 8, to weigh the minimum number of pills we would weigh 2^M pills from each jar, where M = jar# -1.  So, 1 pill from jar 1, 2 from jar 2, 4 from jar 3... up to 2^7=128 pills from jar 8, a total of 255 pills.  With a weighing that is N mg less than 255 grams, translating that value of N to binary, each binary digit instance of 1 will identify a contaminated jar.  E.g. a 1 in the LSB place means jar 1 is contaminated, a 1 in the 4th LSB place means jar 4 is contaminated, etc. 

    (Pro pharmacy tip:  Please put 8 containers on the scale (and zero out the scale), each container devoted to the pills from a particular jar, and keep track of which pills came from which jar so we needn't mix all the pills for the weighing and have to throw them all away!)

  • 1. Label the eight jars 1 to 8. Take pill/s from the jars according to their label. Take one pill from jar 1, two pills from jar 2, …, and eight pills from jar 8. Weigh all pills (36 pills) taken from the jars. To get the number of jar that has contaminated pills, subtract the measured weight to the total weight when all pills are medicine. Suppose jar 3 has contaminated pills, 36(1000) - 1(1000) - 2(1000) - 3(999) - 4(1000) - 5(1000) - 6(1000) - 7(1000) - 8(1000) = 36000 - 1000 - 2000 - 2997 - 3000 - 4000 - 5000 - 6000 - 7000 - 8000 = 36000 - 35997 = 3. The other jars will have medicine pills.

    2. Label the eight jars 1, 10000, 100000000, …, 10000000000000000000000000000. Add four zeroes on the label of the next jar. The same as number 1, take pill/s from the jars according to their label. To get the label of jar/s that has contaminated pills, subtract the measured weight to the total weight when all pills are medicine. Suppose jars with label 1 and 10000 have contaminated pills, 10001000100010001000100010001(1000) - 10000000000000000000000000000(1000) - 1000000000000000000000000(1000) - 100000000000000000000(1000) - 10000000000000000(1000) - 1000000000000(1000) - 100000000(1000) - 10000(999) - 1(999) = 10001000100010001000100010001000 - 10001000100010001000100009990999 = 10001. The answer indicates that jar 10000 + jar 1 have contaminated pills.

  • 1. Take out 1 pill from jar 1, 2 pills from jar 2, 3 pills from jar 3, 4 pills from jar 4 and 5 pills from jar 5 up until the 8th jar. Put all these 36 pills on the scale. The correct weight is  (36*1000) which is 36000. But one of the jars has contaminated pills. So the weight will definitely be less than 3600. If the weight is 35900 then jar 1 has contaminated pills because there is only one contaminated pill. If the weight is 35800 then jar 2, if the weight is 35700 then jar 3, if 35600 then jar 4, if 35500 then jar 5, 35400 then jar 6, 35300 then jar 7, and 35200 then jar 8.

    2.  With powers of 2, same mechanism as discussed in #1. Get 1 pill in Jar 1, 2 pills in Jar 2, 4 pills in Jar 3, and so on until the total is 255. The correct weight should be (255*1) = 255. We will then know if which jar has contaminated pills if weighting all the pills and then converting them to a binary number with the ones with a 0 bit corresponds to the Jar with contamination. E.g. If the total weight is 254, converting it to binary is 1111 1110 which means Jar 1 is the one with the contaminated pill. 

  • Q1: Take 1 pill for jar 1, 2 for jar 2, 3 for jar 3... The difference between measurement and expected weight will give you the contaminated pills jar number.

    Q2: Same logic but combination between jars pills must give a sum that is unique for every combination. Thus, the measurement will give you the only possible combination. One possibility is:

    number of pills _ from jar number

    1 _ 1,

    2 _ 2,

    4 _ 3,

    8 _ 4,

    13 _ 5,

    22 _ 6,

    46 _ 7,

    69 _ 8