3 fruit basket puzzle

Vikas Kore
2 min readJun 20, 2024

--

While browsing through Instagram stories, I came across this puzzle and was fascinated by how we solve it.

Credit www.pinterest.com

Puzzle

There are 3 baskets labeled ‘Apples’, ‘Oranges’ & ‘Apple+Oranges’. One of them contains only Apples, one only Oranges and one has mix of apples and oranges both.
These all 3 baskets are labeled incorrectly. In fact, the labels on these baskets always lie. (i.e. if the label says Oranges, Then you are sure the basket either has only Apples or Mixture).
You are allowed to pick one fruit from one basket. You have to put all the labels correctly by seeing only one fruit from any one basket.
How will you do that ?

Solution

Pick a fruit from the basket labeled ‘Apple+Oranges’. We know from the question that this basket does not contain both fruits for sure.

  1. If this fruit is an apple, then label this Basket as ‘Apple’ (Because this basket does not contain Mixture, so if one is apple, all are apples only). Now we’ve determined that the basket labeled as ‘Mixture’ only contains Apples.
    We know that since the label is incorrect, since we know that the basket labeled as ‘Oranges’ contains ‘Apple+Oranges’ (because ‘Apples’ basket we already found. So label it as ‘Apple+Oranges’. The remaining basket will be labeled as ‘Oranges’.

You can apply the same logic if you assume you initially picked an orange from the basket labeled as ‘Apple+Oranges’.

Ok, lets try this in Swift language using ChatGPT, you can get its tested implementation here.

Thank you.

--

--

Vikas Kore
Vikas Kore

No responses yet