Balls in Boxes

I stumbled upon a cute puzzle on Facebook which originally came from a new book, Creative Puzzles to Ignite Your Mind by Shyam Sunder Gupta.

Puzzle. We have four identical boxes. One of the boxes contains three black balls (BBB), another box has two black and one white balls (BBW), the third box has one black and two white balls (BWW), and the last box has three white balls (WWW). Four labels, BBB, BBW, BWW, and WWW, are put on the boxes, one per box. As is often the case in such puzzles, none of the labels match the contents, and this fact is common knowledge. Four sages get one box each. Each sage sees his label but doesn’t know the other’s labels. Without looking in the box, each sage is asked to take out two balls and guess the color of the third ball. All the sages are in the same room and can hear each other and see the colors of the balls that are taken out.

  • The first sage takes out two black balls and says, “I know the color of the third ball.”
  • The second sage takes out one black and one white ball and says, “I know the color of the third ball.”
  • The third sage takes out two white balls and says, “I don’t know the color of the third ball.”
  • The fourth sage says, without taking out any balls, “I know the color of all the balls in my box and also the content of all the other boxes.”

Can you figure out what’s in the boxes?


Share:Facebooktwitterredditpinterestlinkedinmail

15 Comments

  1. Adam Hesterberg:

    (rot13) Qbrfa’g gur guveq fntr xabj gung gur sbhegu fntr’f obk vf ynoryrq gevcyr-juvgr, fb gur sbhegu fntr’f obk pna’g or gevcyr-juvgr, fb gur guveq fntr’f obk zhfg or gur gevcyr juvgr?

  2. SI:

    For Adam

    Qbrfa’g gur guveq fntr xabj gung gur sbhegu fntr’f obk vf ynoryrq gevcyr-juvgr, fb gur sbhegu fntr’f obk pna’g or gevcyr-juvgr, fb gur guveq fntr’f obk zhfg or gur gevcyr juvgr?

    Ab. Gur guveq fntr bayl xabjf gung gur svefg gjb fntrf unir gjb bs gur svefg guerr obkrf. Nf gur guveq fntr pna’g frr gur ynory bs gur sbhegu fntr’f obk, gur guveq obk vf fgvyy va cynl.

  3. Shyam Sunder Gupta:

    I am not able to read the comments. Can it be properly converted into English?

  4. tanyakh:

    Shyam,

    The comments use ROT13 cypher. You can find the decoder online. This happens because people do not want to provide spoilers.

  5. Shyam Sunder Gupta:

    Thank you for clarification. Thank you for including this puzzle from my book “Creative Puzzles to Ignite your Mind” in your wonderful blog. I admire your website.
    I also have similar interest authoring more than 600 sequences in OEIS and my popular website on number recreations http://www.shyamsundergupta.com
    Regards,

  6. Sanandan Swaminathan:

    I may be misinterpreting something, but I don’t see why the THIRD sage wasn’t able to decipher his third color, and in fact, everyone’s colors and labels. I’m assuming that the four sages spoke in the given order. Common knowledge problems can go off in different directions depending on synchronicity or order of responses or any thinking time from the sages involved. Here I assume linear order with no thinking time factor. I also assume that all the sages made thoughtful and true statements based on the information they had when their turn to speak came.

    Notation: A string like BBB represents label BBB on a box with actual contents BBW. Also, when four boxes are shown as a list below, the first box generally refers to the sage formulating the list, but the other boxes are not in any specific order of sages unless explicitly stated.

    S1 saw two black balls. If S1 saw label WWW on his box, he would be torn between the following two possibilities (as an example) for the four boxes:
    WWW, BBW, BWW, BBB
    versus
    WWW, BBB, BBW, BWW

    All the labels are incorrect in both scenarios (as desired). So if S1 saw label WWW, and picked out two black balls from his box, he couldn’t be sure whether the actual contents were BBW or BBB. Thus he would be unsure of his third color. Similarly, if S1 saw label BWW, he would be torn between the following two possibilities for the four boxes, for example:
    BWW, BBW, BBB, WWW
    versus
    BWW, BBB, BBW, WWW

    Since labels WWW and BWW are ruled out for S1, the label he saw must have been BBB or BBW. If he saw label BBB and two black balls, the contents must have been , and if he saw label BBW, the contents must have been . Thus S1 could determine his third color. Just knowing that S1 picked two black balls and was able to determine his third color, each of the remaining three sages can independently come to a similar (not same) conclusion on his own – that S1 has either BBB or BBW. Sages S2, S3 and S4 can all reach this conclusion without knowing what label S1 saw, in fact without even looking at their own labels or picking two balls from their boxes.

    Sage S2 saw a black and a white ball, so the actual contents of his box are or . If S2 saw label BBB, he would be torn between the following possibilities, as an example. Here, since S2 has label BBB, S1 must have BBW as established before (we check this to ensure that S2’s dilemma is consistent with what he knows about S1).
    BBB, BBW, BWW, WWW
    versus
    BBB, BBW, WWW, BWW

    Similarly, if S2 saw label WWW, he would be torn between the following possibilities, as an example:
    WWW, BWW, BBB, BBW
    versus
    WWW, BWW, BBW, BBB

    Thus, S2 necessarily had label BBW or BWW. Given that he saw a black and a white ball, he had either BBW or BWW, and was able to determine his third color. At this point, the remaining two sages would independently determine that S2 must have either BBW or BWW. They previously knew that S1 has either BBB or BBW. Armed with this information, we can look at the possibilities. This time, the lists are shown in order of sages S1, S2, S3, S4.

    1. BBB, BBW, BWW, WWW, or
    2. BBW, BWW, BBB, WWW, or
    3. BBW, BWW, WWW, BBB

    Note that the following are NOT possible:
    1. BBB, BBW, BWW(BBB), WWW because S3 saw two white balls. Also, WWW is not possible as label and contents match.
    2. BBB, BBW, WWW, BWW because S3 saw two white balls.
    3. BBB, BBW, WWW, BWW due to WWW.
    4. S1 having BBB and S2 having BWW since that would mean S1 and S2 have the same contents.
    5. BBW, BWW, BBB(BWW), WWW due to WWW.
    6. BBW, BWW, WWW, BBB(BWW) due to WWW.

    S3 picks two white balls. From the three possibilities listed, depending on whether S3’s label is BWW, BBB or WWW, he not only knows his own third color but knows everyone’s colors and labels, including sage S4’s. Any of the three labels BWW, BBB or WWW that S3 might have map to a distinct set of labels and contents (of all four boxes) from S3’s perspective at this point in time.

    In fact, if the distribution (in order of sages) was…
    1. BBB, BBW, BWW, WWW, or
    2. BBW, BWW, BBB, WWW
    … then sage S4, staring at label WWW, wouldn’t be able to determine his own third color without picking a ball or two from his box. If the first ball S4 picks is white, then he knows that the distribution is BBW, BWW, BBB, WWW, and thus his own third color and everyone else’s labels and colors. On the other hand, if the first ball is black, then S4 needs to pick a second ball to determine which of the two distributions above is in play. Of course, if S4 saw label BBB, then he knows (without picking a single ball) that the distribution is BBW, BWW, WWW, BBB.

  7. Sanandan Swaminathan:

    Reposting with angle brackets replaced by parentheses as WordPress filters contents in angle brackets. The strings in parentheses represent the actual content of the boxes.

    I may be misinterpreting something, but I don’t see why the THIRD sage wasn’t able to decipher his third color, and in fact, everyone’s colors and labels. I’m assuming that the four sages spoke in the given order. Common knowledge problems can go off in different directions depending on synchronicity or order of responses or any thinking time from the sages involved. Here I assume linear order with no thinking time factor. I also assume that all the sages made thoughtful and true statements based on the information they had when their turn to speak came.

    Notation: A string like BBB(BBW) represents label BBB on a box with actual contents BBW. Also, when four boxes are shown as a list below, the first box generally refers to the sage formulating the list, but the other boxes are not in any specific order of sages unless explicitly stated.

    S1 saw two black balls. If S1 saw label WWW on his box, he would be torn between the following two possibilities (as an example) for the four boxes:
    WWW(BBW), BBW(WWW), BWW(BBB), BBB(BWW)
    versus
    WWW(BBB), BBB(WWW), BBW(BWW), BWW(BBW)

    All the labels are incorrect in both scenarios (as desired). So if S1 saw label WWW, and picked out two black balls from his box, he couldn’t be sure whether the actual contents were BBW or BBB. Thus he would be unsure of his third color. Similarly, if S1 saw label BWW, he would be torn between the following two possibilities for the four boxes, for example:
    BWW(BBW), BBW(BWW), BBB(WWW), WWW(BBB)
    versus
    BWW(BBB), BBB(BWW), BBW(WWW), WWW(BBW)

    Since labels WWW and BWW are ruled out for S1, the label he saw must have been BBB or BBW. If he saw label BBB and two black balls, the contents must have been (BBW), and if he saw label BBW, the contents must have been (BBB). Thus S1 could determine his third color. Just knowing that S1 picked two black balls and was able to determine his third color, each of the remaining three sages can independently come to a similar (not same) conclusion on his own – that S1 has either BBB(BBW) or BBW(BBB). Sages S2, S3 and S4 can all reach this conclusion without knowing what label S1 saw, in fact without even looking at their own labels or picking two balls from their boxes.

    Sage S2 saw a black and a white ball, so the actual contents of his box are (BBW) or (BWW). If S2 saw label BBB, he would be torn between the following possibilities, as an example. Here, since S2 has label BBB, S1 must have BBW(BBB) as established before (we check this to ensure that S2’s dilemma is consistent with what he knows about S1).
    BBB(BBW), BBW(BBB), BWW(WWW), WWW(BWW)
    versus
    BBB(BWW), BBW(BBB), WWW(BBW), BWW(WWW)

    Similarly, if S2 saw label WWW, he would be torn between the following possibilities, as an example:
    WWW(BBW), BWW(WWW), BBB(BWW), BBW(BBB)
    versus
    WWW(BWW), BWW(WWW), BBW(BBB), BBB(BBW)

    Thus, S2 necessarily had label BBW or BWW. Given that he saw a black and a white ball, he had either BBW(BWW) or BWW(BBW), and was able to determine his third color. At this point, the remaining two sages would independently determine that S2 must have either BBW(BWW) or BWW(BBW). They previously knew that S1 has either BBB(BBW) or BBW(BBB). Armed with this information, we can look at the possibilities. This time, the lists are shown in order of sages S1, S2, S3, S4.

    1. BBB(BBW), BBW(BWW), BWW(WWW), WWW(BBB), or
    2. BBW(BBB), BWW(BBW), BBB(WWW), WWW(BWW), or
    3. BBW(BBB), BWW(BBW), WWW(BWW), BBB(WWW)

    Note that the following are NOT possible:
    1. BBB(BBW), BBW(BWW), BWW(BBB), WWW(WWW) because S3 saw two white balls. Also, WWW(WWW) is not possible as label and contents match.
    2. BBB(BBW), BBW(BWW), WWW(BBB), BWW(WWW) because S3 saw two white balls.
    3. BBB(BBW), BBW(BWW), WWW(WWW), BWW(BBB) due to WWW(WWW).
    4. S1 having BBB(BBW) and S2 having BWW(BBW) since that would mean S1 and S2 have the same contents.
    5. BBW(BBB), BWW(BBW), BBB(BWW), WWW(WWW) due to WWW(WWW).
    6. BBW(BBB), BWW(BBW), WWW(WWW), BBB(BWW) due to WWW(WWW).

    S3 picks two white balls. From the three possibilities listed, depending on whether S3’s label is BWW, BBB or WWW, he not only knows his own third color but knows everyone’s colors and labels, including sage S4’s. Any of the three labels BWW, BBB or WWW that S3 might have map to a distinct set of labels and contents (of all four boxes) from S3’s perspective at this point in time.

    In fact, if the distribution (in order of sages) was…
    1. BBB(BBW), BBW(BWW), BWW(WWW), WWW(BBB), or
    2. BBW(BBB), BWW(BBW), BBB(WWW), WWW(BWW)
    … then sage S4, staring at label WWW, wouldn’t be able to determine his own third color without picking a ball or two from his box. If the first ball S4 picks is white, then he knows that the distribution is BBW(BBB), BWW(BBW), BBB(WWW), WWW(BWW), and thus his own third color and everyone else’s labels and colors. On the other hand, if the first ball is black, then S4 needs to pick a second ball to determine which of the two distributions above is in play. Of course, if S4 saw label BBB, then he knows (without picking a single ball) that the distribution is BBW(BBB), BWW(BBW), WWW(BWW), BBB(WWW).

  8. lvps1000vm:

    I agree with the two people above that the problem must be wrong:
    – The two first sages have two of the three boxes BBB, BBW, BWW. Thus not having the box WWW.
    – The two first sages have two of the three labels BBB, BBW, BWW. Thus not having the label WWW.
    – The third sage needs only to read his label: He has either the label WWW or the box WWW.

  9. Sanandan Swaminathan:

    For Ivps1000vm:

    If sage S3 has label WWW, then he does need to pick one or two balls from his own box to determine the actual contents of his own box. Using the notation BBB(BBW) when label is BBB and actual box content is BBW, there are 4 possibilities before S3 picks any ball. These are in order of boxes of sages S1, S2, S3, S4.
    1. BBB(BBW), BBW(BWW), BWW(WWW), WWW(BBB), or
    2. BBW(BBB), BWW(BBW), BBB(WWW), WWW(BWW), or
    3. BBW(BBB), BWW(BBW), WWW(BWW), BBB(WWW), or
    4. BBB(BBW), BBW(BWW), WWW(BBB), BWW(WWW)

    If S3 has label BWW or BBB (possibilities 1 and 2 above), then indeed S3 knows that his box contains WWW as you mentioned, even without picking a single ball. In fact, in cases 1 or 2, S3 knows everyone’s labels and colors too, including S4’s, without picking a ball.

    However, if S3’s label is WWW, as shown in cases 3 and 4 above, he cannot be sure about the actual contents of his box without picking a ball or two. If the distribution is as shown in #3, then his box contains BWW. If the distribution is as shown in #4, then his box contains BBB. So, if S3’s label is WWW, he should first pick one ball. If it is white, then he knows that the distribution is BBW(BBB), BWW(BBW), WWW(BWW), BBB(WWW), and thus knows the colors of the other two balls in his box as well as everyone else’s labels and colors. But if the first ball S3 picks is black, then he will need to pick one more ball. If the second ball is white, then he knows that the distribution is BBW(BBB), BWW(BBW), WWW(BWW), BBB(WWW. If the second ball is also black, then he knows that the distribution is BBB(BBW), BBW(BWW), WWW(BBB), BWW(WWW). So, in the worst case, sage S3 knows his own third color and everyone else’s labels and colors after picking two balls.

  10. lvps1000vm:

    Yes, you’re right — he needs to extract the two WW balls AND read the label. Then, as we agree, he cannot claim he doesn’t know the color.

  11. Shyam Sunder Gupta:

    Each sage knows his label only and not the label of other sages.
    Statement of sages are not to be violated.

  12. Sanandan Swaminathan:

    Shyam, the conditions are clear. What we are saying is that the problem itself seems inconsistent. There appears to be no scenario is which the third sage can truthfully say that he does not know the color of the third ball in his box.
    It is clear from the problem description that there are four different labels; no label matches the box on which it is affixed and all four sages know about this before they start; the only label a sage can directly see is the label on his own box; sages go in the order 1, 2, 3, 4; when any sage picks two balls, all the sages can see the colors of the two balls picked and can also hear the guess the sage announced; statements of the sages are not to be violated.
    As shown in a post before, under these conditions, the third sage cannot say that he does not know his own third color because he is guaranteed to know it, at least after picking two white balls. In fact, at this point, the third sage is guaranteed to know the contents and labels of all the four boxes, not just his own.
    If you like, you could post your solution, and we can try to point out the flaw in it in terms of why it’s not consistent with the third sage saying that he does not know his third color.

  13. Sanandan Swaminathan:

    One of the statements in my posting above should read “… and can also hear the statement the sage said”.

  14. Shyam Sunder Gupta:

    Sanandan, While your detailed analysis is appreciable, as far as the puzzle is concerned, there appear to be some assumptions and contradictions in the approach. For example, you are assuming that Sage 3 is making a true statement. You are also confirming that “statements of the sages are not to be violated”. Based on the statements of Sages 1 and 2, you are concluding something, but for Sage 3, you are analysing based on the conclusions of Sages 1 and 2 and giving a judgement on the statement of Sage 3, which is a contradiction in approach. In fact, if “statements of the sages are not to be violated,” then for Sage 3 also, you must assume his statement as correct (whether it is true or not) and then find the possible labels and contents. This approach will be in line with the approach you adopted for Sage 1 and Sage 2.

  15. Sanandan Swaminathan:

    Maybe I’m misinterpreting your point about sage S3’s statement being correct versus true. I’m only looking at it from S3’s perspective. Assume that sage S2’s statement is just done, and sage S3 hasn’t even bothered to look at his own label yet. Based on S1 and S2’s turns, sage S3 can only see four possibilities remaining (without looking at his own label):
    1. BBB(BBW), BBW(BWW), BWW(WWW), WWW(BBB), or
    2. BBW(BBB), BWW(BBW), BBB(WWW), WWW(BWW), or
    3. BBW(BBB), BWW(BBW), WWW(BWW), BBB(WWW), or
    4. BBB(BBW), BBW(BWW), WWW(BBB), BWW(WWW)
    Above, the boxes are shown in the order of sages S1, S2, S3, S4. The actual box contents are in parentheses, and the labels are outside parentheses.
    The four possibilities for S3 are BWW(WWW) or BBB(WWW) or WWW(BWW) or WWW(BBB). Now, if S3 glances at his own label without picking any ball, and if the label is BWW or BBB, then S3 immediately knows that his own box contents are WWW. On the other hand, if his label is WWW, then S3 can’t yet be sure if his box contents are BWW or BBB. But then he picks two white balls, so he knows that his actual box contents are BWW. There seems to be no situation in which S3 does not know the color of his third ball after looking at his own label and picking two white balls. So how can S3 say that he does not know the color of his third ball? Are we to assume that S3 is making a false statement? If yes, are we to assume that any of the four sages could be making true or false statements?

Leave a comment