'man-in-the-middle' attack on data being transfered over Network
June 11, 2012
Difference between lvalue and rvalue expressions
June 11, 2012

3 basket puzzle (Apple/Orange Puzzle)

There are 3 baskets labeled ‘Apples’, ‘Oranges’ & ‘Mixture’. One of them contains only Apples, one only Oranges and  one has mix of apples and oranges both.
These baskets are not labeled correctly. 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 (Not allowed to see other fruits), and you have to put all the labels correctly on the basis of that information (by seeing only one fruit from any one basket).
How will you do that ?

Solution:

Pick a fruit from the basket labeled ‘Mixture’. We know from the question that this basket does not contain ‘Mixture’ 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.
  2. If we look at the basket labeled as ‘Oranges’, we know that since the label is incorrect, this basket either has only apples in it or has Mixture. Since we already know which basket contains only apples, we know that the basket labeled as ‘Oranges’ contains ‘Mixture’. So label it as ‘Mixture’. The 3rd 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 ‘Mixture’.

4 Comments

  1. 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.

  2. put the apples and oranges in s_p_r_t_ in basket

Leave a Reply

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