# The Twins and the Number of Candies

Yveti and Xerni are twins. Their mischievous friend, Cubo, one day decides to give them a riddle.

Cubo comes up to them and says, "I have two bags of candies in my bag. The first of you two to guess the number of candies in each bag will get both bags. And yes, there is more than just 2 candies, so get excited!"

Cubo first tells Xerni the total number of candies. Cubo then tells Yveti the product of the two number of candies.

He leaves, waiting for one of the twins to figure out the seemingly impossible puzzle.

Xerni after a long time, complains, "I can't figure it out!"

Yveti replies, "Me too!"

Xerni, after hearing this, yells, "I got it!"

Yveti, hearing the reply, says, "Me too!"

What was the number of candies in each bag?

• I am not totally sure but is this question seems duplicate of this question. It is totally related though Jun 11, 2016 at 10:20
• Not the same as that one -- that one has sum and difference rather than sum and product. Jun 11, 2016 at 10:21
• I'm pretty sure this one is well known and I would be very unsurprised if it's already been posted here, though. Jun 11, 2016 at 10:21
• Does the order of bags matter ? Jun 11, 2016 at 17:00
• This reminds me of the "Cheryl's birthday question" from the Singaporean maths challenge Jun 12, 2016 at 6:03

My assumption is that the "more than 2" hint applied to the number of candies in each of the two bags

(8,3)

Yveti and Xerni know that there mus be more than 2 candies in each bag

Yveti is told the product is 24 but needs to choose two possible answers (3,8) and (4,6)

Xerni is told the sum is 11 but needs to choose three possible answers (3,8) (4,7) and (5,6)

Once Yveti says "I cant figure it out then the answer becomes clear.

If the answer was (4,7) whose product is 28, Yveti would immediately know the sum was 11 (4,7) since factors (2,14) would leave only 2 candies in one bag.

If the answer was (5,6) whose product is 30, Yveti would know the sum was either 13 (3,10) or 11 (5,6) since 17 (2,15) would leave only 2 candies in one bag. Two options remain

If the answer was (3,8) whose product is 24 the Yveti would know the sum was 10 (6,4) or 11 (3, 8) since 14 (2,12) would leave only 2 candies in one bag. Two options remain

If the sum was 10 (7,3) or (6,4) than Xerni would know the know that if Yveti was told the product was 21 (7,3) then Yveti could answer right away because there is no other solution.

Since Yveti did not answer right away the answer cannot have sum of 10. Since the sum is 11 and (5,6) and (7,4) already are excluded (for the reasons above) the answer by process of elimination is

(8,3)

product 24, sum 11 neither can answer on their own but after

Xerni after a long time, complains, "I can't figure it out!" Yveti replies, "Me too!"

then Xerni and Yveti could

• (Forwarded comment:) Hi all, it appears I might not have enough reputation to comment on others answers. But could someone please explain ... how Xerni ruled out (5,6)? Luke states that (5,6) was "already excluded (for reasons above)" but I don't think it was or could be ruled out since there are two possibilities for a product of 30, (5,6) and (3,10). Sorry, if I'm missing something obvious. – flu
– humn
Jun 14, 2016 at 18:12

I'll assume (though the question doesn't say that X and Y are brilliant reasoners who quickly draw all logical conclusions from any information they have, and who never make arithmetic mistakes, and that both of them know this, and that both of them know that, etc.

So, we have two numbers A and B. X is told their sum S=A+B and Y is told their product P=AB. They are both told that S>2. Clearly this implies P>1. They both want to work out {A,B}.

What would it take for X to be able to work it out immediately? S would have to be 3 (which would yield only the solution {1,2}). Any other value of S would permit at least {1,S-1} and {2,S-2}. So when X admits defeat, everyone knows that S>3 (and nothing else).

[Note: there used to be a typo in the previous paragraph, which is what Malandy's comment below is about.]

What would it take for Y to be able to work it out now? P would have to be prime (which would yield only {1,P}). Any other choice of P yields multiple solutions with S>3. (Suppose P is not prime. Let p be a prime dividing P; then we have {1,P} and {p,P/p}. These are not the same solution because p is neither 1 nor P. They both have sum>3 because the only way to make either add up to 3 is to take P=2, which is prime.) So when Y admits defeat, everyone knows that S>3 and P is composite (and nothing else).

This is enough for X. How can that be? Of the options {1,S-1}, {2,S-2}, etc., there must be exactly one for which the product is composite. That's really restrictive. If S>5 then {2,S-2} and {3,S-3} are distinct and both yield composite products. If S=4 then the options are {1,3} with product 3, prime, and {2,2} with product 4, composite -- so this works -- and if S=5 then the options are {1,4}, composite, and {2,3}, composite -- so this doesn't work. So S=4, P=4, and each bag has 2 candies, and at this point everyone knows this.

So we didn't actually need to be shown Y saying "Me too!" at the end. Which is a bit disappointing, it seems to me. (Perhaps my reasoning is wrong somewhere?)

See here: I don't know the two numbers... but now I do and here: Product and Sum for more difficult versions of this problem (both numbers are known to be >2, and P rather than S goes first). They have very different answers, the main reason for which is that in the first we have one player telling the other "I knew you didn't know" which adds some subtlety.

• My assumption was the requirement meant more than 2 candies in each bag. I excluded 2 as a possible factor for the product told to Yveti for that reason. Am I wrong?
– Luke
Jun 11, 2016 at 12:18
• You're ignoring the possibility of zero candies in a bag. Your final answer and most of your reasoning are still correct, but Xerni's first statement doesn't rule anything the possibility S=3. Jun 11, 2016 at 16:56
• only the solution {1,3}) I think you mean {1,2}? 'Cause 1+3 = 4, and 1+2 = 3? Jun 11, 2016 at 17:08
• Mike: "two bags of candies". A bag containing zero candies cannot reasonably be described as a "bag of candies". Jun 11, 2016 at 17:37
• Malandy, yes, I meant to write {1,2}. I'll fix it. Jun 11, 2016 at 17:38

4 and 6

X was told 10, so could be (3,7), (4,6) or (5,5). So she doesn't know right away.

Y was told 24, so could be (3,8) or (4,6). So she also couldn't know.

X could suspect (4,6) at this point, since if it were (3,7) or (5,5), then Y would have figured it out right away. But still X couldn't know for sure what number Y was given.

X admits she can't possibly know.

Y says she can't figure it out either. Upon hearing this, X can now immediately rule out (3,7) and (5,5). So X knows it's (4,6).

X says she now knows. Upon hearing this, Y can now rule out (3,8) since if the sum was 11, X couldn't have figured it out as X would have had to consider (4,7) and (5,6) as possibilities. (4,7) could be ruled out since 28 is the only product. But (5,6) could not since 30 could be made with (5,6) or (3,10). So the only way X could have known by now is if she was given the sum of 10, not 11. Thus Y now also knows it's (4,6).

• Hi all, it appears I might not have enough reputation to comment on others answers. But could someone please explain why in the voted answer above how Xerni ruled out (5,6)? Luke states that (5,6) was "already excluded (for reasons above)" but I don't think it was or could be ruled out since there are two possibilities for a product of 30, (5,6) and (3,10). Sorry, if I'm missing something obvious.
– flu
Jun 14, 2016 at 15:17
• Your question is now a comment to that answer, @flu. Someone will probably take the time to reply there. The first 50 points, required to leave comments anywhere, are indeed the most valuable!
– humn
Jun 14, 2016 at 18:15