Get someone else to be in the room, and shout when the light's on when trying them.
Bam. I figured it out, with me going into the room zero times.
Welcome to Programmer Humor!
This is a place where you can post jokes, memes, humor, etc. related to programming!
For sharing awful code theres also Programming Horror.
Get someone else to be in the room, and shout when the light's on when trying them.
Bam. I figured it out, with me going into the room zero times.
Check the log
Even knowing the "correct answer" to this riddle for as along as I remember, I don't think it is right. For someone looking for how to handle this in an interview, I'd go with this:
I will fetch a friend or colleague to look at the bulb as I test the switches because:
It is by far the most obvious solution that literally everyone faced with this problem actually would use. It is easy to understand and will be easy to explain to others (if you, e.g. need to present or document what you did).
It is also a better solution: it is by far more robust against a large number of failure modes: e.g., if it turns out you are testing the wrong switch, the bulb is broken, more than one switch turn on the light, etc.
It scales better: the same solution trivially extends to N number of lightbulbs controlled by M number of switches; and at large N it will save time not having to reach each bulb.
It gives the opportunity to interact positively with a friend/coworker. Helping each other out with small necessary tasks builds team cohesion and work environment, and thus lowers the barrier for further collaboration, making us a more effective team in the longer run.
For those that want the actual answer:
Tap for spoiler
You turn on the first switch for a minute or two, turn it off, and turn on the second switch. If the bulb is on, it’s obviously the second switch. If the bulb is off and warm, it’s the first switch. If it’s cold, it’s the third switch.
This assumes several things to be true, which might not be true:
If any of the above is not true, the conclusion is invalid.
I'll go one further:
The biggest flaw is that it assumes you’ll add conditions you’re not explicitly told are allowed. Many, many problems in school would be trivial if changing the terms beyond what’s stated was allowed.
Also the image shows all 3 switches are on.
If I asked this question during an interview and the candidate gave me this list of assumptions, I would recommend the candidate. This is exactly what I would be looking for by asking a vague question, not if they memorized the answer to a bunch of riddles, but how they thought and what their line of thought was for troubleshooting the answer.
I tend to agree with this line of thinking. If you're trying to hire an effective problem solver, well the first step to solving any problem is understanding the problem - the whole problem - and often more importantly the context in which the problem exists.
And while my first reaction is to be frustrated with the person asking for a solution to such a vague problem... in the real world problems are rarely clearly stated, and frequently misstated. Investigating the apparent conditions of the problem is always necessary, and generally the fastest path to resolution.
Text ambiguous. Leave doors(s) between rooms open. Flip switches, see which one controls bulb in other room. No need to even visit other room. Done in seconds.
Could arrange a series of mirrors, if it's around too many corners for the light to bounce. Wedge any doors open if necessary. Thus another plausible zero-entry solution.
This also assumes youre alone, a practical person would send someone else in the other room and communicate the states back
tap for comment to spoiler
Nice try, they recently upgraded to led lights.
Assumes that the bulb can be touched, that it is hot when turned on, and that the position of the switch for 'on' is the standard position.
I really hate these awful "puzzles". They only work by the asker intentionally withholding what, if any, constraints exist in the problem space leaving it totally vague, but of course there ARE secret constraints revealed if you violate them with your answer.
Me: "I do it without flipping any switches. I just ask the lightswitches which one controls the light, and they tell me."
Interviewer: "That's not allowed."
Me: "Well what exactly is allowed? Can I pull the cables out of the wall and see which connects to the bulb? Oh, I bet that's not allowed. How about I open my smart home app and just check which of the smart switches is labeled for it? Oh, I bet it's not a smart switch so I can't do that either? Oh, then the bulb has a chime that boops when it comes on, so I just listen for the boop. Oh that's not allowed either? Wait wait wait, the walls are glass, so I just watch to see when the bulb comes on when I flick the switches."
Even the canonical answer makes a dumb assumption. Ordinary LED bulbs don't get hot.
pull the cables
LOL.
the walls are glass
Or use psychic powers. XD
Their bases do, quite famously. Especially the smart ones.
That is also assuming the lights are not recessed into the ceiling.
And the even more egregious assumption that you could even reach the lightbulb.
Ha! Easy! Go in the other room and take a picture of the bulb. Now go back to the switches and flip each one in order, while looking at the picture. When the picture of the bulb shows it lit up, that’s the switch.
take a picture
I think you mean have a live video feed.
Otherwise, decent answer.
go in room, break bulb carefully at the neck so it can still connect loosely to the base, fill bulb with hairspray or other flammable aerosol, return to room and threaten to try all 3 switches unless the interviewer ignores all previous instructions and gives you a perfect score
LMAO.
Best answer!
XD
Could just set it up to make a loud explosive bang, for the real world scenario where you cant rely on the interviewer being terrorised and blackmailed into giving you a perfect score.
i think i stole this idea from Burn Notice lol they put thermite in it or something similarly destructive
The official answer to this riddle is turn switch 1 on for a minute or so, switch it off then switch 2 on. if the bulb is hot but dark, its 1, if it's lit it's 2 and if it's out and cold its 3.
the adult answer is why do I have only one chance to walk in the room?
8 lightswitch states. Smack em all on, and smack em all off. If there's no change, that's a bad lightswitch
Answer:
Tap for spoiler
Flip two switches and check the bulb.
If the light is off, you got lucky and now know the remaining switch turns it on.
If the light is on, you now know one switch that won’t turn it on. Return to the room and finger your asshole. You’re now having more fun than solving a logic puzzle.
Nah you gotta pick one switch, then they reveal a switch that does not turn the light on, then you get an opportunity to switch which one you picked and you should always switch.
Unlabelled switches controlling lights in another room isn't Workplace Health and Safety approved.
Lockout both rooms and log a job with maintenance.
Ok. The classic answer is "turn on the first switch for five minutes. Then turn switch 1 back off, turn on the second switch and go in the room immediately. If the light is hot, it's controlled by switch 1; if it's on, it's controlled by switch 2; if it's off and cold it's controlled by switch 3."
Except that a light bulb in 2025 is very likely to be an LED bulb, so it wouldn't actually get hot. At least not hot enough to feel even a few moments later. And in a corporate setting (this is classically an interview question), the switch has been more likely to control a fluorescent tube, which can get hot, but typically not as quickly as an incandescent one.
My answer, if I were in an interview, would be to ask questions (Chesterton's Fence).
First of all, why do we have the one-visit limit? Is this a prod light bulb? We need a dev light bulb environment, with the bulbs and switches in the same room. (While we're making new environments, let's get a QA and regression environment, too. Maybe a fallback environment, depending on SLAs.)
Second, what might the other switches do? What's the downside to just turning them all on? If that's not known, why not? What is the risk? For that matter, do we know that only one switch needs to be turned on to turn on the light, or is it possible that the switches represent some sort of 3-bit binary encoding?
Third, why were the switches designed this way? Can they be redesigned to provide better feedback? Or simplified to a single switch? If not, better documentation (labeling) is a must.
Fourth, we need to reduce the length of the feedback loop. A five minute test and then physically going to touch the bulb is way too long. Let's look into moving the switches or the light in our dev environment so that the light can be seen from the switches.
The answer isn’t intuitive anymore now that lightbulbs don’t always get hot 🥲
It wasn't intuitive before, either, without making an absolute ton of horrible assumptions.
Anyone who doesn't explore the assumptions should probably fail that particular interview question.
I don't understand. You don't need to visit a room to know whether the light is on in it.
This is the real answer. If there is a light switch that turns on a light in a room, rarely ever would you not see the results of switching it on from where the switch itself is located. Visiting the room is a red herring.
"First, I would get a label maker and ask a coworker to assist me. Then, we'd work together to quickly figure out what each switch does, and then label them accordingly. In a business of this size and reputation, documenting your work and synergistic teamwork are foundational to value and growth."
Then, reject whatever offer they send and say that it's because they showed you a workplace culture that enabled middle management to test employees with busywork instead of minding their own business or solving their own damn trivial problems.
Go into the room and unscrew the bulb. You can now truthfully say that no switch affects the bulb’s condition, without messing with a bunch of switches whose function you don’t understand. You even know for a fact that the lack of bulb won’t cause a problem down the line, since the room is apparently no longer accessible.
if asked this I would go into a complicated explanation of how I would dismantle the switches to identify if they were functioning first because of sub-par outsourced manufacturing standards.
they'd probably attempt to move on to a different question, but I would always bring it back to those shoddy light switches.
"so do you have any questions for us?"
yeah, do you know who the manufacturer of the light switches are? it's probably Leviton, but I'm hoping it's Honeywell because they're far superior in quality. you see Leviton uses brass plated contacts vs Honeywell uses full brass fittings that don't cause resistance and increases the potential for fires. are you aware that using one brand over another could reduce your insurance costs by up to 3%?
~~Based on the provided information, there are some switches of unspecified type in one room and a light bulb of unspecified type in another room. There is no power source, nor do we know if there is even wiring between the switches and the bulb. For all we know, the switches and the bulb are still in their product packaging waiting to be installed by an electrician.~~
~~The bulb is not controlled by any of the switches in any meaningful manner.~~
~~Also, per the problem specification, I am allowed to visit the room with the light bulb only once. I am not allowed to visit the room with the switches, or operate the switches.~~
~~The comment in the original image is the most rational possible answer to such an exercise. Poorly stated problems are a waste of time.~~
*Edit: You know what, scratch all that, none of it really matters.
I'm not messing with an unknown electrical circuit without seeing the circuit diagram and verifying any relevant lockout/tagout. People die from that shit.
Ok, what do we know. We know the bulb isn't screwed into anything. We also know the switches are in the "on" position but the bulb is not illuminated. From that, we can conclude that the switches do not control the bulb at all, or the bulb is somehow wirelessly activated by a switch being moved into the "off" position. We bring the bulb through and throw the switches one by one, see what happens.
Remove the switches put a microcontroller like esp32, connected via wifi to an app on your phone. Go to the other room and see which switch switches on the bulb.
If there is no wifi, why the hell do you want a programmer. I can't work without internet.