3 Switches and 3 Light Fixtures

You are in a room with three switches that each control a different light fixture in another room. You cannot see from the switch room into the lamp room. Your task is to determine which switches control which light fixtures, but you may only go into the room with the lights once. How do you determine which switch controls which light?

If asked this during an interview, your interviewer is probably looking for this answer: Flip two switches to the on position and wait a few minutes. Then turn one of those switches off and go directly to the room with the lights. The light that is on is obviously connected to the switch that you left in the on position. The other two lights are off, however the one that you turned on for a while will still be warm and the one that you never turned on will be cool.

These types of questions are posed to help the interviewer get an idea of how you would go about solving a problem. The main issue with this is that many people (possibly including your interviewer) seem to believe that there is one correct answer. Anyone who does any amount of problem solving will be able to tell you that there is always more than one solution to any given problem. Every solution will have both positive and negative aspects to it.

For instance, the above solution is quite elegant under certain conditions. However there are some possible problems with this approach as well. What if the room is far enough away that the time it takes you to get there is greater than the time it takes the bulb to cool? Also consider that some types of lamps (LEDs for instance) do not get very warm to begin with. What happens if you get to the room with the lights and find that they are 30 feet up and you don’t have a ladder (or an instrument to measure the heat)?

My first solution to this problem is incredibly simple. Go find a friend/coworker/janitor/bum give them a piece of paper and pencil and have them go into the room with the lights. Tell them to take notes of which lights turned on and in what order. Compare their notes to your notes of what switches you flipped. Problem solved.

Can’t find someone to help? Grab a webcam and set it up in the room with the lights. Go to the room with the switches and pull up the webcam on a computer in the room with the switches. Flip switches and note which lights turn on. Problem solved.

Don’t have a webcam? Get a long piece of string (note that your clothes are made from string). Turn two switches on and tie the string to one of those switches. Take the other end of the string and walk to the room with the lights, being careful not to pull the string too hard. When you are there carefully pull the string until one of the lights turns off. Problem solved.

Don’t have that much string? Make a simple machine that will flip one light switch. Turn on one switch and set the machine to flip another switch to on. Start the machine and go into the room with the lights. Note which light was on and which light turned on. Problem solved. Note that you could make a machine that could do this using only local office-type supplies, a few of the 6 simple machines and potential energy (the design of said machine I’ll leave to the reader as another problem solving exercise).

Can’t make a simple machine? Pick up the phone and call building maintenance. Problem solved, maybe.

As you can see, there are many solutions to this problem, each of which has advantages and disadvantages. There simply is no correct answer to questions like this. In addition there is almost always a situation where the “correct” answer completely fails to give you a result.

For funnier and more intricate solutions to this problem see What would Feynman do?

Tip for interviewers: Instead of looking for the “correct answer” to these questions, here’s a better approach. Have the candidates list as many solutions as they can think of in a short time. If they don’t come up with a lot of them you can give them additional solutions. Then have them explain what the advantages/disadvantages of each solution would be and any possible pitfalls they see.

If you enjoyed this article, you will probably also like 2 Light Bulbs and a 100 Story Building, another rant about another useless interview question.

And if you want to brush up on basic computer science stuff, check out the What In The Hell Series.