Apple

www.apple.com
Engaged Employer

## Interview Question

Software QA Engineer Interview Cupertino, CA

# There are three boxes, one contains only apples, one

contains only oranges, and one contains both apples and oranges. The boxes have been incorrectly labeled such that no label identifies the actual contents of the box it labels. Opening just one box, and without looking in the box, you take out one piece of fruit. By looking at the fruit, how can you immediately label all of the boxes correctly?
Tags:

This post has been removed.

This post has been removed.

9

The key bit is "All the three boxes are names incorrectly"

so the label on the box which fruit comes from will need to be changes to one of the other 2 labels.

It can only be 1 of them (and it will be obvious when you have the fruit)

then the remaining box (that hasnt featured yet)...Just swap that label with fruit box that was originally on the box which you took the fruit out of

Thats hard for anybody to understand somebody elses explanation...

eaiest way is to just do an example

Swaz on Oct 30, 2010
47

Swaz answer is almost correct however it does not work in all scenarios.

lets assume:
box 1 is labelled Oranges (O)
box 2 is labelled Apples (A)
box 3 is labelled Apples and Oranges (A+O)
and that ALL THREE BOXES ARE LABELLED INCORRECTLY"

Pick a fruit from box 1,

1) if you pick an Orange:
- box 1's real label can only be O or A+O
- box 1's current label is O
- since ALL LABELS ARE INCORRECT then box 1's real label can not be O
- box 1's new label should then be A+O by elimination
- since ALL LABELS ARE INCORRECT
- box 2's label is changed to O
- box 3's label is changed to A
- SOLVED

2) if you pick an Apple:
- box 1's real label can only be A or A+O
- box 1's current label is O
- since ALL LABELS ARE INCORRECT then box 1's real label can not be O
- this still leaves us with the choice between label A and label A+O - which would both be correct
- FAILURE

Solution: The trick is to actually pick a fruit from the A+O labeled box

Pick a fruit from box 3:

1) if you pick an Orange:
- box 3's real label can only be O or A
- box 3's current label is A+O
- since ALL LABELS ARE INCORRECT then box 3's real label can not be A+O
- box 3's new label should then be O by elimination
- since ALL LABELS ARE INCORRECT
- box 1's label is changed to A
- box 2's label is changed to A+O
- SOLVED

2) if you pick an Apple:
- box 3's real label can only be O or A
- box 3's current label is A+O
- since ALL LABELS ARE INCORRECT then box 3's real label can not be A+O
- box 3's new label should then be A by elimination (not O)
- since ALL LABELS ARE INCORRECT
- box 1's label is changed to A+O
- box 2's label is changed to O
- SOLVED

Dan on Dec 30, 2010
3

it only says you can't look, doesn't mean you can't feel around or smell the fruit you picked, easy deduction after you figure the first box out

<---likes it raw on Dec 30, 2010
3

Sagmi is right, but did not give the full reasoning.

"the bax lebeled Apples+Oranges contains only Oranges or Only Apples.
Pick one fruit from it. If it is Orange then lebel the box as Orange."

so far so good

Now, the box labelled Apples cannot be the box containing only Oranges, you've just found that box, so it must contain Apples and Oranges. And in that case the other box, labelled Oranges, must contain only Apples.

Andrew on Dec 31, 2010
14

It's easier to draw it out.

There are only 2 possible combinations when all labels are tagged incorrectly.

All you need to do is pick one fruit from the one marked "Apples + Oranges".

If it's Apple, then change "Apple + Orange" to "Apple"
The "Apple" one change to "Orange"
The "Orange one change to "Apple + Orange"

If it's Orange, then change "Apple + Orange" to "Orange"
The "Apple" one change to "Apple + Orange"
The "Orange" one change to ""Apple"

DC on Jan 4, 2011
0

Since all 3 boxes are labled incorectly Start with the box Labled A&O. If Its apples than the box labled apples then the apple one is oranges and the oranges is O&A.

Tootsie on Jan 8, 2011
4

Label each box "Apples and/or Oranges" and the all will be correct.

Donna on Jan 11, 2011
7

This is very simple to resolve. I was asked the same question at FileMaker.
Each box is incorrectly labeled. So you go to the box that is labeled "Oranges and Apples" and take one out. It doesn't matter what comes out because all that you know is that it is not AO. If you remove an Apple then move the Apple label to it.

Since the Apples are already identified it is easy to resolve the rest. All you know for certain is that the other two boxes remaining are mislabeled. So the AO label goes on the box with the remaining label and that label goes on the Apple box as you have already assigned that. The end result is you only need to remove one piece of fruit to figure out the proper locations of all.

Fericit.Bostan on Jan 11, 2011
0

Go down the road to HP. Maybe they are hiring. Some of these pseudo-problem solving questions like this are bunk. I was once asked why sewer covers are round and not square. I gave the correct answer without even hesitation and the interviewer seemed
put off that I knew the answer. I didn't get the job but, in hindsight, no great loss.

I prefer the questions (like the basketballs one from google) where you won't be able to give an accurate numerical answer but by explaining HOW you would go about solving the problem is all you need to do and MAYBE shows your aptitude for problem solving.

Dave on Jan 11, 2011
1

Smell the box you opened.

Steve on Jan 11, 2011
1

Step 1: Order the boxes by weight. Either apples weigh more than oranges, or oranges weigh more than apples. The mixed box will always be in the middle.

Step 2: Open the first box, take out the fruit and look at it.

Step 3: If the fruit is an apple, deduce that the middle is apple and oranges and that
the third box is oranges. If the fruit is an orange, then deduce that the last is the box with the apples.

Rob on Jan 11, 2011
1

Donna is the only one with any common sense. The problem with corporate America, is that it's run by a bunch of Bozos who over complicate things and have a narrow to zero vision on how to solve even the simplest problems. I can imagine that most of you would get a committee, have long meetings where you talk about 'think out of the box', and 'at the end of the day' nonsense.

Henri on Jan 11, 2011
1

This is an interesting logic question, but I would not want to buy fruit from a company who knew they had a problem and then sampled one out of three boxes to resolve the issue.

asakim on Jan 11, 2011
3

There are other correct answers posted. I'll just make a comment:

"The boxes have been incorrectly labeled such that no label identifies the actual contents of the box it labels."

Nothing in the above statement says the labels are limited to oranges/pears, only that they do not identify the contents. They could say 'nuts', 'bolts', etc.

Technically, all answers should be prefaced with: assume that the labels say 'oranges', 'pears', and 'orange/pears'.

Ok, the problem does not make sense and is unsolvable if the labels say 'x', 'y', 'z', but someone with (likely with a math proof back ground) may appreciate attention to detail.

Q: Why do posters denigrate the interview questions? The questions, however stupid they may be, are a opportunity to show you can build an answer. Even if you pursue an invalid train of thought in the interview, it's a thought. It's what they want to see and what will help you get a job offer.

Note: I also would not assume that the questions asked are a reflection on the company, department, or team as a whole. It may just be the interviewer that has chosen poorly. So to say "I don't want to work for company X because they asked me a stupid interview question" is pretty closed minded. To even think I don't want to work with that interviewer just based on questions asked seems extreme.

e on Jan 11, 2011
0

rightly pointed out by Sagmi ... this question was put forward to me at Huawei Technologies and that was the answer I gave

AR on Jan 12, 2011
7

So the question was asked at an interview for Apple: Label ALL the boxes apple and charge a ridiculous price for them!

CF on Jan 14, 2011
5

Just label all of them "Fruit."

Brendan on Oct 16, 2011
1

Put another way, it is not possible to tell since we don't know how the boxes are mis-labled. What if the Apple box was labeled Oranges and both the other boxes were labeled Apples and no box was labled Apples and Oranges? You might have assumed there are three different labels when their might have only been two different labels.

Gary on Oct 7, 2013
0

Always pict a piece of fruit from the box labelled Apple&Orange.

As we know that this label is wrong, there are two possibilities:

If it is apple, then wo know that this box should be labelled Apple, so we switch Apple label with the label Apple&Orange. Then Apple label is correct. We also know that the Orange label is incorrect, so we then switch Orange label and Apple&Orange label.

if it is orange, then we know that this box should be labelled Orange, so we switch Orange label with label Apple&Orange. Then Orange label is correct. The same as above, we know that the Apple label is incorrect, so we
switch Apple label and Apple&Orange label.

Lin on Dec 16, 2014
0

If all boxes are labeled incorrectly and u pick a orange out of a box that's labeled apple/oranges change the name to oranges then change the box labeled oranges to apples and the the box labeled apples to apple and oranges... If you pick a apple out of a box labeled apples and oranges change the name to apples and then change the box labeled apples to oranges and the last to apples and oranges... If u pick a apple out of a box labeled oranges change it to apples and oranges then the box labeled oranges to apples and the box labeled apples to oranges...if you pic a orange out of a box labeled apples change it to apples and oranges and the box labeled oranges to apples and the last to apples and oranges... See the pattern?

Drae on Jan 24, 2015
0

I think there is a big box and it contain two small boxes and all the labels are incorrect so big one contain two boxes that makes it carrys both orange and apples and in that thwo boxes having orange and apple respectively so if we open any box we can label it correctly

Shoaib on Apr 14, 2015
0

To see the java source code of puzzle, visit: https://github.com/SanjayMadnani/com.opteamix.microthon
code is taking the input by console only. You can fork or clone the repository and proceed further. You can also rise bug if you find any.
Run BasketPuzzleGameTest.java class as a Junit test case to start game.

Sanjay Madnani. on Jun 23, 2015