Hi guys, I need someone to help me solve this problem. The conditions in the statement are very strict:

APPLES AND PEARS
Tom has three boxes with fruits in his barn: one box with apples, one box with pears, and one box with both apples and pears. The boxes have labels that describe the contents, but none of these labels is on the right box. How can Tom, by taking only one piece of fruit from one box, determine what each of the boxes contains?

The key is in the line "none of the labels are on the right box".
When you pull one fruit out of each box you're going to get 2 apples and 1 pear or 2 pears and 1 apple.
For example, if you reach into the box labeled apples and pull out an apple you know it is the mixed box because it can't be the apple box (the label is wrong). Alternatively, the same result works for the box marked pears. Given you only have three boxes, one must give you a fruit that it says it can't. You can re-label all of the boxes after that.

The trick is you can only pull one fruit from one box, not from each box. So you have to pull from the box marked "apples and pears" since this label is wrong the box must contain only pears or only apples, so which ever you draw you have determined the contents of the box.

If you draw an apple from the "A&P" box then you know this box is just apples thus box marked "pears" has to contain both A&P since it also has to be wrong and the "apples" box must contain just pears.

Just swap the names around for the solution if you draw a pear from the "A&P" box.

no need to draw anything out of the boxes. Just open them and look inside...

Yes, that's a trick answer to a trick question.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.