Log Date

Welcome to techInterview, a site for technical interview questions, brain teasers, puzzles, quizzles (whatever the heck those are) and other things that make you think!





  1. Text post

    Jelly Beans

    You have three jars that are all mislabeled. one contains peanut butter jelly beans, another grape jelly jelly beans, and the third has a mix of both (not necessarily a 50/50 mix, could be a 1/99 mix or a 399/22 mix). how many jelly beans would you have to pull out, and out of which jars, to find out how to fix the labels on the jars?

    |     |        |     |          |     |
    |jar 1| |jar 2| |jar 3|
    | | | | | |
    ======= ======= =======
    p.b. grape p.b./grape

    thanks to joel wollman

    Solution

    You have three jars that are all mislabeled. one contains peanut butter jelly beans, another grape jelly jelly beans, and the third has a mix of both (not necessarily a 50/50 mix, could be a 1/99 mix or a 399/22 mix). how many jelly beans would you have to pull out, and out of which jars, to find out how to fix the labels on the jars?

       |     |                  |     |                 |     |
    |jar 1| |jar 2| |jar 3|
    | | | | | |
    ======= ======= =======
    p.b. grape p.b./grape

    solution: 1 jelly bean from the p.b./grape jar will do the trick.

    the trick here is to realize that every jar is mislabeled. therefore you know that the peanut butter jelly bean jar is not the penut butter jelly bean jar, and the same goes for the rest.

    you also need to realize that it is the jar labeled p.b./grape, labelled as the mix jar, that is your best hope. if you choose a jelly bean out of there, then you will know whether that jar is peanut butter or grape jelly jelly beans. it can’t be the mix jar because i already said that every jar is mislabeled.

    once you know that jar 3 is either peanut butter, or grape jelly, then you know the other jars also. if it is peanut butter, then jar 2 must be mixed because it can’t be grape (as its labelled) and it can’t be peanut butter (that’s jar 3). hence jar 1 is grape.

    if jar 3 is grape, then you know jar 1 must be the mix because it can’t be p.b. (as its labelled) and it can’t be grape (that’s jar 3). hence jar 2 is peanut butter.

    if you pick jelly beans from jar 1 or jar 2, then you would have to pick out all of the jelly beans before you knew what that jar was. this is because jar 1 and 2 could be the mix, so in order to disprove that they were the mix, you would have to pull out every jelly bean just to make sure (since there could just be one bean of the opposite flavor in there)

Tumblr Theme 'Nautical' by PixelUnion