CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 12 of 12
  1. #1
    Join Date
    Aug 2012
    Posts
    3

    Developer Interview Question

    I was not able to answer this Technical Interview Logic Question
    Can some one help me.

    LOGIC PROBLEM -- There are three boxes. One labeled “Nickels” another “Quarters” another “Nickels and Quarters”. They are all mislabeled. How could you select ONE item from ONE box and figure out how to relabel the boxes correctly.

  2. #2
    Join Date
    Jan 2006
    Location
    Singapore
    Posts
    6,765

    Re: Developer Interview Question

    Hint: all the boxes are mislabeled. From this, you can determine the two possibilities of what they currently contain. By picking one item from any box, you can thus rule out the other possibility for that box, which then allows you to rule out the possibilities from the other boxes.
    C + C++ Compiler: MinGW port of GCC
    Build + Version Control System: SCons + Bazaar

    Look up a C/C++ Reference and learn How To Ask Questions The Smart Way
    Kindly rate my posts if you found them useful

  3. #3
    Join Date
    May 2009
    Posts
    2,413

    Re: Developer Interview Question

    The key to this quiz is that all boxes are mislabeled.

    Say you order the three boxes according to how they're actually labeled (N=nickels, Q=quarters, N&Q=nickles and quarters) like this,

    N, Q, N&Q

    Now since all are mislabeled what are the alternatives to label them corrrectly? It's,

    Q or N&Q, N or N&Q, N or Q

    That would be 2*2*2=8 possible combinations in total but since each label can appear once only there are just two correct labelings possible,

    1: Q, N&Q, N
    2: N&Q, N, Q

    Finally how do you decide which of these two possibilities you actually have? Well, you pick an item out of the third box labeled N&Q. If it's an N the first labeling is correct, if it's a Q it's the second.
    Last edited by nuzzle; August 12th, 2012 at 05:11 AM.

  4. #4
    Join Date
    May 2009
    Posts
    2,413

    Re: Developer Interview Question

    Quote Originally Posted by laserlight View Post
    By picking one item from any box, you can thus rule out the other possibility for that box, which then allows you to rule out the possibilities from the other boxes.
    Sorry, I didn't notice you had replied while I was working out my reply.

    But is your hint correct? According to my solution you must pick exactly from the box labeled N&Q to get a conclusive result. For example if you happen to pick a Q out of the N-labeled box you cannot decide which labeling is correct. Only if you get lucky and pick an N can you tell.
    Last edited by nuzzle; August 12th, 2012 at 05:32 AM.

  5. #5
    Join Date
    Jan 2006
    Location
    Singapore
    Posts
    6,765

    Re: Developer Interview Question

    Quote Originally Posted by nuzzle
    But is your hint correct? According to my solution you must pick exactly from the box labeled N&Q to get a conclusive result. For example if you happen to pick a Q out of the N-labeled box you cannot decide which labeling is correct. Only if you get lucky and pick an N can you tell.
    Ah, no, you are right to say that only picking from the box labeled N&Q are you guaranteed to be able to rule out the other possibility. (Though I could "cheat" and say that I wanted Enthuse0809 to work through a deliberately inaccurate hint instead of taking it at face value )
    C + C++ Compiler: MinGW port of GCC
    Build + Version Control System: SCons + Bazaar

    Look up a C/C++ Reference and learn How To Ask Questions The Smart Way
    Kindly rate my posts if you found them useful

  6. #6
    Join Date
    Aug 2012
    Posts
    3

    Re: Developer Interview Question

    Thank you both laserlight & nuzzle. I got it now.

  7. #7
    Join Date
    Feb 2002
    Posts
    4,640

    Re: Developer Interview Question

    My favorite has always been:
    You're in a room with two doors, and two other people. One door leads out, and one leads nowhere. One person in the room always tells the truth, the other person always lies. What *one* question could you ask, *one* of the other people in the room, to figure out which door leads out?



    Viggy

  8. #8
    Join Date
    Jan 2010
    Posts
    1,133

    Re: Developer Interview Question

    Could you open the exit door for me?

    EDIT:
    Or any door for that matter. The person doesn't have to know the right one.
    But, there is a problem... A legitimate answer to that question is "No."...
    D4mn...
    Last edited by TheGreatCthulhu; August 13th, 2012 at 12:27 PM.

  9. #9
    Join Date
    Jan 2010
    Posts
    1,133

    Re: Developer Interview Question

    I know!
    What would the other guy say about this door? And than pick the opposite - the one that the other guy would (supposedly) claim to "lead nowhere".
    Code:
    Honest  --+-----e-----L(w)-------- [exit] -------H(w)------w-----+-- Liar
               \                                                    /
                +---w-----L(e)-------- [wall] -------H(e)------e---+
    Last edited by TheGreatCthulhu; August 13th, 2012 at 12:41 PM.

  10. #10
    Join Date
    May 2009
    Posts
    2,413

    Re: Developer Interview Question

    It seems both quizzes have a common denominator they may share with most quizzes of this kind: There's a certain dependency between alternatives and once you "see" it the solution presents itself as obvious and trivial.

    In the first quiz, given that all boxes are mislabeled, by drawing an item from the N&Q box there's just one labeling possible.

    In the second quiz, given that both other persons know whether the other is a liar or not and they're asked to ask each other, whoever you ask the reply will be a lie.

    The big quiz here I'd say is whether quizzes like these have a place in an interview for programmer? I don't think so because they're based on a moment of laid-back enlightment. If you're familiar with the quiz you'll look like a genius but if not even an Einstein may run into trouble in a stressful interview situation.
    Last edited by nuzzle; August 15th, 2012 at 12:20 AM.

  11. #11
    Join Date
    Jan 2006
    Location
    Singapore
    Posts
    6,765

    Re: Developer Interview Question

    Quote Originally Posted by nuzzle
    The big quiz I'd say here is whether quizzes like these have a place in an interview for programmer? I don't think so because they're based on a moment of laid-back enlightment. If you're familiar with the quiz you'll look like a genius but if not even an Einstein will get into trouble in a stressful interview situation.
    Yeah, on one hand, there's the element of constraint programming, and if the candidate were to think out loud, the interviewer can get an idea of the candidate's logical thinking skills even if he/she gets stuck or comes up with a wrong answer; on the other hand, it can be considered one of those trick puzzles where you're either very lucky to see the solution, or you know the solution beforehand, neither of which tells the interviewer anything about the candidate's logical thinking skills.
    C + C++ Compiler: MinGW port of GCC
    Build + Version Control System: SCons + Bazaar

    Look up a C/C++ Reference and learn How To Ask Questions The Smart Way
    Kindly rate my posts if you found them useful

  12. #12
    Join Date
    Jan 2010
    Posts
    1,133

    Re: Developer Interview Question

    Which means that in such cases it all boils down to whether the person conducting the interview qualifies for his own job of an interviewer, and indeed what are the intentions behind the question.
    If the purpose behind it is to make a preliminary assessment of candidate's logical thinking skills, possibly important for the job - then it's not a big deal. EDIT: Actually, a fair thing to do would be to inform the candidate that it is not necessary to produce the solution to the next question, and that the purpose is to perform a little exercise logical reasoning.
    If it's a can-you-meet-my-out-of-nowhere-criteria test, where the criteria are based on personal unfounded assumptions, or some supposedly generic quick-and-easy candidate litmus test - then there's a problem, and no place for the question in the interview.

    Which makes me wonder: Enthuse0809, were you practicing for a future interview, or did this happen on an actual interview? If the latter, how did the interviewer react?
    Last edited by TheGreatCthulhu; August 14th, 2012 at 09:03 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured