There are three identical boxes of apples and oranges, except one contains all apples, one contains all oranges, and one contains a mix.

The boxes are labeled “apples”, “oranges”, and “apples and oranges” but *all 3 boxes were labeled incorrectly*!

You have the opportunity to inspect fruit from the boxes one at a time, without looking inside the box. What is the fewest number of fruit you need to inspect to correctly label the contents of the identical boxes?

This was a popular brainteaser in some engineering interviews a while back, including a software quality assurance engineer interview at Apple.

Preparing for a brain teaser interview? Check out our ultimate guide to brain teaser interviews.

#### Solution

In order to label all the boxes correctly, you only need to inspect one fruit from one box! The key here is that the labels are not just random, you know they are *all incorrect*.

- Open the box labeled apples and oranges. Since this is incorrectly labeled, whatever fruit you see must reflect the full contents of that box. Let’s say you saw an apple, so this box must be “apples”.
- Now consider the box labeled “oranges”. Since it is incorrectly labeled, it cannot contain oranges. And since the “apples” box has already been identified, it cannot contain apples. So it must contain “apples and oranges”.
- By process of elimination, the remaining box must be “oranges”.

## 2 replies on “Boxes of Apples and Oranges”

We have to inspect only one box…

We can take out a ball from the “1 red 1 blue” box. It’s stated that all boxes are incorrect, therefore we have two options for first box’s label (“2 Red or 2 Blue). If took out a blue ball, then that box must be “2 blue”.

For the two remaining boxes, the box labeled “2 red” must be incorrect as all boxes are incorrect and will be two remaining possible labels (“1 red 1 blue” or “2 red”). But it’s already incorrectly labeled “2 red” therefore it must be “1 red 1 blue”. This leaves one remaining choice for our last box “1 red 1 blue”. Therefore we can just use one widget/box (“1 red 1 blue” box) to correctly label all boxes.