Check the log
Unlabelled switches controlling lights in another room isn't Workplace Health and Safety approved.
Lockout both rooms and log a job with maintenance.
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.
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.
Remove the switches put a microcontroller like esp32
ESP32 proceeds to explode with 230VAC
Don't worry I power it with a Chinese adapter nothing of blowing up happens here. Also I have an app for it.
What bothers me about this specific question, apart from it being dated, is that it breaks the rules of these kind of riddles. They're implied to be in a sort of frictionless sphere universe, the whole preposition is silly except as an abstract puzzle. To then rely on the physical properties of real lamps is cheating. You're supposed to ignore all the real-world aspects of the setting except that one.
Agreed, it presents as an abstract logic puzzle, but then gives a very concrete answer. It’s like presenting the trolly problem to someone, and when they give one of the two expected answers saying “no, stupid, you run ahead and untie the victims before the trolly reaches them.”
It’s compounded by the fact that the proposed physical solution isn’t even very reliable, as lots of people in this thread have said. If we’re stepping outside of the logic puzzle constraints, why not just leave the door to the room open? Or have someone stand inside and shout when the light turns on? Or ask someone who knows these switches? Or any number of boring non-brain teaser solutions.
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.
This question becomes more a test of age as time goes. I've been asked this question even after the movement towards all-LEDs.
This question is also stupid, both because it has a correct question and because almost certainly some people have advantages over others that have nothing to do with the actual job.
20+ years ago? Sure, this was a somewhat viable question. But now? It's incredibly messy.
Over my years, I've asked dozens of very, very smart people from all kinds of walks of life, extremely smart to seemingly dumb as hell - nobody has ever gotten it right.
Probably the only thing this question is good for is seeing how an applicant does when faced with a diplomatic situation and a really dumb interviewer.
I'm super curious what the people who unironically ask this question think they're testing.
It's a silly riddle that, for some reason, has stuck around in my head for decades, I think from an old tv show (anyone else remember Crashbox?). I remembered the answer immediately. So, this would be less of a test of my reasoning/problem solving skills, and more of a test of my ability to find and store vast amounts of useless trivia and instantly recall it decades after the fact. If that's what you're hiring for, I'm your guy!
I’ve walked out of interviews that had these popular puzzle questions in the 00s. The company you’re interviewing for is not testing you for your job, it wants a corporate drone that is ok with bureaucracy and can navigate the red tape they’ve put in place.
Really a waste of time, but if I run into this at my age now I ask if they can tell me how their company is making something for the betterment of human kind.
Knowing full well this would be coming from a FAANG company, a funnier answer would be to replace the switch with the equivalent smarthome switch, and then spend the next 20 minutes explaining their uttery stupid network pathway from your phone, through the cloud, back to your device to turn on a lightbulb.
I once had an interviewer ask me what happens when you type a domain into your browser and hit enter. "Use as much detail as you want."
Well, I did...
"For the sake of brevity, I'll start when the user presses the Enter key. As the key goes down, it makes two contacts connect, passing a current..."
It depends on what type of person designed the circuit and what type of person you are.
Ergonomics: The switch closest to the door first, then mid, then far, figuring the unknown user would click the switch closest, a skilled electrician would start there. However, it's not unreasonable for the electrician to ask the owner, so this is a hit-or-miss approach.
Installation efficiency: The installer refused to mark any of the lines and instead hooked them up at random, flip in any order, when you find the right one, return the others to the original state.
time efficiency: the energy cost to flip all three switches is minimal and you're only going in once, flip all three at the same time. you've done maximum effort and maximum time savings.
Error reduction, binary counter, all combinations tested in case of chained switching
Debugging: binary counter, followed by checking the lightbulb, possibly swapping for another if one is nearby, checking all the other switches near the room, breakers, power to the structure, and asking an occupant for assistance as a last resort.
Disaster recovery: locate a flashlight or use your phone's torch/flashlight function.
Ahh crap, other room.
-
ask an occupant
-
shove a penny in the socket behind the light bulb and listen for a breaker to pop
-
turn all three on
-
slide your cell phone under the door with video recording on, stomp on the floor hard every time you flip a switch
-
turn all the switches through a binary counter looking for one that seems to do nothing.
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:
- power is available/the upstream circuit is on (always a bad assumption to make)
- the bulb is an incandescent type that will generate an appreciable amount of heat in a short amount of time
- the bulb was in the off state before you changed the position of any switches, and has been off long enough to be cold
- the bulb is connected to any of the switches
- the bulb is connected to only one of the switches (parallel circuits are a thing, as are multi-switch lighting circuits)
If any of the above is not true, the conclusion is invalid.
I'll go one further:
- Assumes the bulb is in reach. When I read the problem I assumed the bulb was in a ceiling fixture out of reach. Nowhere in the text description did it specify the physical location, except "in the other room".
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.
I can't believe not even a single person said "use a touchfree current detector".
At least I could argue back that's expected to be allowed if this circumstance happened IRL
Programmer Humor
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.
Rules
- Keep content in english
- No advertisements
- Posts must be related to programming or programmer topics