Categories

# Wrongly Labeled Boxes

You run a small business that sells and ships widgets. Today, you received three orders: one customer bought two blue widgets, one bought two red widgets, and one bought one red and one blue widget. Each widget is carefully packaged without any indication of the color inside, and then you pack the each order of two packaged widgets into boxes, tape them up, and stick shipping labels on them using your digital label printer.

However, there was a glitch with the software, and it labeled all three boxes incorrectly. You need to figure out the correct labels, but you forgot which box contained which widgets.

What is the fewest number of widgets you have to inspect before you know how to correctly label all the boxes, and which do you inspect?

This was a popular brainteaser in some engineering interviews a while back, often using “apples” and “oranges” instead of red and blue widgets.

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 widget from one box! The key here is that the labels are not just random, you know they are all incorrect.

1. Open the box labeled one red and one blue. Since this is incorrectly labeled, whichever color the widget you inspect is, the box must contain two widgets of that color. Let’s say you find a blue widget, then this box must contain two blue widgets.
2. Now consider the box labeled two red. Since it is incorrectly labeled, it cannot contain two red widgets. Since the box with two blue widgets has already been identified, it cannot contain two blue widgets. So it must contain one red and one blue widget.
3. By process of elimination, the remaining box labeled one red and one blue must contain two red widgets.

## 2 replies on “Wrongly Labeled Boxes”

Amit Goelsays:

We have to inspect only one box…

Wills Liousays:

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.