Interview Question: Boxes of Apples, Oranges and Mixed

This question has repeatedly come up during face to face interviewers of one specific company here in Toronto, Canada. It is supposed to test programming logic. You may judge for yourself its effectiveness. Trick interview questions such as these are controversial. Do such questions really show IT intelligence and talent or are they used as a chance method to eliminate candidates? One web site, CareerCup.com has a collected a database of such interview questions.

Q: There are three covered boxes that are all mislabeled: one contains “apples”, one contains “oranges”, one contains “mixed”. You cannot see the contents of these boxes. You may stick your hand into one box at a time and take out a fruit. How do you correctly relabel the boxes?

A: The boxes are all mislabeled. Stick your hand into the box labeled “mixed”.

Step 1a: If you take out an apple, then this is the apple box. The original “mixed” label is incorrect (given), therefore the only possible options are apples or oranges. Switch the labels between the “mixed” and “apple” boxes. The original mixed box becomes the apple box. The original apple box becomes the mixed box. The apple box is now correctly labeled.

The box originally mislabeled “orange” (given) must be the mixed box. Its options are apple or mixed, and since the apple box is already correctly labeled (step 1a), there is no other choice but mixed. The final box must be the orange box.

Step1b: If you take out an orange, then this is the orange box. The original “mixed” label is incorrect (given), therefore the only possible options are apples or oranges. Switch the labels between the “mixed” and “orange” boxes. The original mixed box becomes the orange box. The original orange box becomes the mixed box. The orange box is now correctly labeled.

The box originally mislabeled “apple” (given) must be the mixed box. Its options are orange or mixed, and since the orange box is already correctly labeled, there is no other choice but mixed. The final box must be the apple box.

Note: If the original labels may be incorrect, then while you can correctly label one fruit, the other fruit and mixed will be more difficult to determine. You will need to pull sucessive fruits from each box until you see both oranges and apples coming from the same box. This may take many tries. If one box is apples and the mixed box has oranges at the bottom and apples on the top, then you would have to continue to select fruit until you have exhausted the mixed box’s apples.

Leave a Reply

Your email address will not be published. Required fields are marked *