Fellow ibiblian Sayan was recently telling me about his experience at an interview, where he was presented with this challenge:
There is a room with 3 lights in it (each with one bulb), controlled by 3 switches outside the room. We don’t know which switch controls which light. How do we figure this out, with only entering the room one time?
When interviewing for tech companies, these brainteasers are a pretty common part of the interview. Another one that I was recently asked:
We have a 3 quart jug and a 5 quart jug and an infinite supply of water. How do we measure out 4 quarts of water?
(The “solutions” are at the bottom of this post)
These two questions are good examples because they demonstrate the two main categories of interview brainteasers:
The first type of question tests the interviewee’s ability to map out a problem space, aka to think “outside” the box (what I like to call “not ignoring most of the box”). In the light bulb question, a successful interviewee will think “wait a second, there are more variables here than the interviewer explicitly mentioned using english words. Light bulbs also… create heat!”.
So the challenge is to think of variables that were not explicitly mentioned. This also implies that you can use tools (a stepstool or a ladder) and perform actions (touch the light bulbs) that were not explicitly mentioned. The essence of the challenge is restrictioning information, tools, and activities. There are no labels on the light switches, you can’t peer around the corner while you flip the switches on and off, and you can only enter the room once. All of these restrictions are artificial things that you would never experience in the real world. And that’s fine. The point of asking anyone anything in an interview is because there is neither time nor resources to see how the candidate performs on a 6 month project with a real client.
BUT, if I can use a ladder, why can’t I use a sledge hammer to break down the wall? Or better yet, buy 2 or 3 $10 mirrors and set them up so I can see the bulbs go on and off. It sounds absurd, but how is that more absurd than not being able to enter a room twice?
Okay, let’s say we’ll put a little more faith in the validity of the universe of the question. Let’s say that the reason we can’t enter the room twice, or peak around the corner, OR set up mirrors, is because the switches are too far away from the bulbs. Well then wouldn’t the second bulb possibly warm up by the time we walked from the switches to the bulbs, so that, within the resolution of heat perception of human skin, it is the same temperature as the first bulb?
Let’s say that the restrictions on tools and actions represent limited resources in a project, but the ladder is an acceptable tool because it’s cheap. Okay, you, reader, sitting there reading this. Do you own a ladder? Now, do you own 2 computers, a web camera, and a wireless router?
Yes, the ladder is cheaper, if you don’t have any of the above. But since the average programmer / consultant is more likely to have 2 computers, a web-camera, and a wireless router, is that not the more efficient solution? Somebody tell me what I’m missing here.
These questions ask you to map out a problem space, but which dimensions are considered “outside of the box”, and which dimensions are considered silly, is completely dictated by the predetermined outcome devised by the question designer. And this is supposed to identify the candidates who have innovative thinking skills?
The jugs problem represents the second type of interview brainteaser. These questions are pretty much a test of raw math and reasoning skills. They aren’t a horrible idea in and of themselves, but I still question their usefulness in an interview context. Everyone is going to get the answer to the jugs problem, the only question is will it take 30 seconds, 3 minutes, or — if the person is anxious — longer than that. So there are only two things that can be ascertained from a candidate’s performance with this question: [1] the raw time that it took for them to find the solutions, [2] how they perform, in terms of reasoning path and self confidence, while finding the answer.
Regarding [1], of all the things you can learn from someone during an interview, are you really going to learn that much more about their intellectual ability by seeing how many seconds it takes them to manipulate jug volumes in their mind?
Furthermore, (while we’re still talking about raw time to the solution), there are more variables than math and reasoning skills at play here. A perfectly capable and sharp interviewee might be very nervous about the interview, being around new people, or being in the unfamiliar environment of a new city. I realize that most adults aren’t nervous wrecks during interviews, but it doesn’t take much anxiety to double the time it takes to do artificial math problems, when for the past 30 hours you’ve been worrying about traveling, printing resumes, getting directions to a new building, and giving a good first impression at a social and professional level.
Given that the interviewer probably doesn’t have a stopwatch on hand, factor [2] is probably the primary purpose of the question. Do companies really want to hire adults in their 20s and 30s who feel totally normal while being commanded to think of solutions to brainteasers from middle school math club (which is the first time i saw the jugs problem)? To me this would indicate that the interviewee suffers from social maladjustment, or even a personality disorder. In fact, this type of situation is an example of the core apparatus of coercion employed by car salesmen, the CIA, and cult leaders: inducing the subject to regress into a childlike state.
On top of that, most candidates will be at least somewhat aware that their demeanor is being observed. So now you have a bunch of candidates putting on something of a show, smoothly and casually talking through their reasoning process. Or just trying to not look stressed. When I’m doing my best work, I’m not looking unstressed and socially smooth. I’m shaking my knee up and down, sucking down green tea, jamming to music, occasionally picking my ear, and occasionally doing celebratory funky dances in my adjustable chair, all while wearing anti-RSI wrist splints.
When I was asked the jugs problem a couple months ago, I didn’t even have time to get to it because I was too busy scrambling around trying to figure out string manipulation in C, which I haven’t done in 7 years. In-interview programming questions are another issue, and the topic for a future essay. Stay tuned…
- Turn on the first switch for a few minutes, then turn on the second one and immediately go into the room. The bulb that is warm is the first switch, the other bulb that is on is the second switch, and the bulb that is off is the third switch.
- Fill up 5QT, use it to fill 3QT, leaving 2 quarts in 5QT. Empty 3QT, then pour the 2 quarts in 5QT into 3QT. This leaves a 1 quart void in 3QT. Fill up 5QT and release a quart into this void, and you end up with 4 quarts in 5QT.
You should start your answer with, “I do my best thinking in the nude or playing a video game — pick.”
I hate interview brain teasers and the people who pose them. I have an acquaintance who loves to pose such questions to interviewees, and he’s an arrogant ass of a person, so it all seems to fit.
IF they have to ask a question, they should ask a question for which the interviewer doesn’t know the answer, but not one which is a clever “no possible answer” type question. Something mundane, not something too hard, something that someone may actually be having a problem with. See how they think about something when the answer is unknown to all involved (god forbid the interviewer has to think too). The best answers may have a little to do with how to think about the logical problem and a little to do with things like deciding to go ask the guy who set up the database a question, or why the sales rep. thought he needed X, etc.
Canned question and answers are a bad measure of thinking skills. (And they’re biased against people who have been out of school longer, and who, ironically, may have much better real-world experience to contribute.) It’s why school examinations are such inaccurate measures of anything but one’s ability to take a test. “Book smart and street stupid,” as a old boss of mine used to say.
Another way to solve the jugs problem. This assumes that the jugs are not tapered in shape (a cylinder, square, rectangle, etc. would work).
In a non-tapered container you can determine half-way full by holding the container at an angle. When the fluid is touching the lip of the container and the opposing bottom corner the container is half full.
Here is a poorly illustrated example:
,'\ ,' \ ,' \ ,' \ ,' \ ,' \ ,' \ \@ \ \@@@ \ \@@@@@ \ \@@@@@@@@ \ \@@@@@@@@@@@ \ \@@@@@@@@@@@@@@ \ \@@@@@@@@@@@@@@@@@ \ \@@@@@@@@@@@@@@@@@@@@\ \@@@@@@@@@@@@@@@@@@,' \@@@@@@@@@@@@@@@,' \@@@@@@@@@@@@,' \@@@@@@@@@,' \@@@@@@,' \@@@,' \,'Fill up 5QT halfway = 2.5QT
Fill up 3QT halfway = 1.5QT
Pour content of 3QT into 5QT = 4QT
solution for the second prob:
fill up the 5 quart jugg.pour it to the 3 quart and stop pouring when the 3 quart jugg is full.now the 5 quart jugg will contain 2 quart of water.mark this level.empty 3 quart and fill it with 2 quart water from the 5 quart jugg.fill 5 quart up to the previously marked level(2 quart) and fill with the 2 quart stored in the 3quart jugg.now it ll be 4 quart