554

Post:

You have three switches in one room and a single light bulb in another room. You are allowed to visit the room with the light bulb only once. How do you figure out which switch controls the bulb? Write your answer in the comments before looking at other answers.


Comment:

If this were an interview question, the correct response would be "Do you have any relevant questions for me? Because have a long list of things that more deserving of my precious time than to think about this!

top 50 comments
sorted by: hot top controversial new old
[-] gtrcoi@programming.dev 2 points 2 days ago

Check the log

[-] quinkin@lemmy.world 43 points 6 days ago

Unlabelled switches controlling lights in another room isn't Workplace Health and Safety approved.

Lockout both rooms and log a job with maintenance.

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?

[-] tetris11@feddit.uk 1 points 2 days ago

8 lightswitch states. Smack em all on, and smack em all off. If there's no change, that's a bad lightswitch

[-] mojofrododojo@lemmy.world 13 points 6 days ago

if the bulb is hot

if hot they're using out of date lighting, who the fuck uses incandescent bulbs this far into the 21st century? they have failed their interview with me.

[-] m4xie@lemmy.ca 8 points 6 days ago

The image does depict an incandescent filament bulb.

[-] Dremor@lemmy.world 4 points 6 days ago* (last edited 6 days ago)

LED do not have a 100% efficiency, and do produce waste heat. A lot less than an incandescence one, sure, but enough for that answer to be valid.
Well, maybe you'd better wait 10min instead of one, to make sure the led lightbulb heats enough, but still...

[-] fruitcantfly@programming.dev 7 points 6 days ago

Well, maybe you’d better wait 10min instead of one, to make sure the led lightbulb heats enough, but still…

I tested this with a 5W IKEA LED light-bulb, since I was just doom scrolling, anyway:

  • After 1 minute of being on, the bulb was still room temperature.
  • After 10 minutes of being on, the bulb was lukewarm.
  • After 10 minutes of being off, the bulb was room temperature, though the fitting maybe felt slightly warmer. That latter will probably depend on your installation, and how well it is able to disperse the heat.

This means that the solution either breaks down entirely, or is unreliable, since you are not (reliably) able to tell the first two buttons apart

load more comments (4 replies)
[-] luciferofastora@feddit.org 3 points 6 days ago

The question is outdated as fuck too. It's not a new riddle.

You know, we're talking about how pointless a riddle it is. "Why can't I walk into the room more than once?" I've heard similar hiring riddles about things like "You've got ten ethernet cables that run the length of a long hallway. They're not marked at either end, what's the most efficient way of finding out which is which?"

And you know what? If I'm hiring a networking guy, I don't want him to deliver me an "ooh I know this one" answer to that, I want him to tell me he's got a cable tester with several remote probes so he can figure that out in a small number of trips. Maybe show me how he can hook a couple together with a coupler and use the cable length function to shave a couple of trips off. Not recite a memorized brain teaser answer.

[-] luciferofastora@feddit.org 1 points 2 days ago

Thr difference in phrasing is that your question presents a reasonable objective rather than an unreasonable constraint. You're also asking something subject-specific from someone who ought to be versed in that subject. That's not a riddle, it's a task you're expecting your hire to be capable of.

That's kind of my point. Google started that nonsense of making job interviews into lateral thinking puzzles, then all managers latched onto that to make themselves look hip.

I want to see competence and practical problem solving skills.

load more comments (1 replies)
[-] pyre@lemmy.world 9 points 6 days ago

this is the classic answer but it also fails pure logic because the question only implies one of them actually works, and even then, it's only one of them. the truth is any number of them could work, or a specific combination, or a number of combinations, or it might be none. the bulb itself to could be busted. my point is not to be an uncooperative asshole but that a logic puzzle that relies on real world properties should cover its bases.

[-] PonderingPotato@discuss.tchncs.de 11 points 6 days ago

So I can't go to the other room to set up a camera?

[-] saimen@feddit.org 8 points 6 days ago

LED bulbs do get warm, not as hot as incandescent bulbs but they do emit heat. You might have to run them longer than a minute to warm it up enough to be immediate about it.

[-] vivalapivo@lemmy.today 4 points 6 days ago

the adult answer is why do I have only one chance to walk in the room?

The actual adult answer is questioning why the switch is in a different room and if it's because of safety, demand for safety protocol

[-] usernamefactory@lemmy.ca 25 points 6 days ago

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.

[-] reddit_sux@lemmy.world 20 points 6 days ago

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.

load more comments (2 replies)
[-] fartographer@lemmy.world 32 points 6 days ago

"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.

[-] strlcpy@lemmy.sdf.org 14 points 6 days ago

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.

[-] usernamefactory@lemmy.ca 15 points 6 days ago

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.

[-] backgroundcow@lemmy.world 2 points 4 days ago* (last edited 4 days ago)

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.

[-] SCmSTR@lemmy.blahaj.zone 14 points 6 days ago

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.

[-] kryptonianCodeMonkey@lemmy.world 12 points 6 days ago

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!

[-] umbraroze@slrpnk.net 15 points 6 days ago

I'll look through the door.

Or, set up a webcam to see when the light is on.

If this isn't allowed somehow, I'll tell the building management to consider rewiring this absolutely cursed light switch situation ASAP because it's gotten so bad that it's being used as a brainteaser by the recruiting department

[-] Modern_medicine_isnt@lemmy.world 14 points 6 days ago

I would say, I do enjoy riddles, so this will be fun. But I am concerned that if you think my skill at riddles is critical, that it may mean your management has gotten used to not fully thinking through the objectives they give and how those objectives interact with the existing systems or other objectives. That would result in the kind of product that looks like the right hand doesn't know what the left is doing. If that is your reasoning for the question, how is the company countering it to create a coherent product.

And the reason I might say this is tgat in my experience, companies who ask such questions aren't the kind I want to work for.

[-] Stupidmanager@lemmy.world 5 points 5 days ago

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.

[-] sga@piefed.social 14 points 6 days ago

After reading the incandescent bulb solution, and problems regarding touching the bulb, i would switch first switch on for a appreciably long time, such that bulb has hit maximum luminousity (they heat up as they run, the hotter they get, the brighter they are), then turn switch off, and turn second switch on and quicky run to other room. we are trying to observe change in luminousity as time elapses. if it reduces, it was first (we ran it for a long time, there would be some residual glow, from my irl observations from when i was small suggest roughly 1 min period where i can still tell, but bulb wattage, contrat with background and distance matter). if increasing or max luminous, then second, if nothing then third.

but it was a stupid question. my naive guess was it can not be done, because with just 1 binary observation, you can not tell from 3 switches (you need atleast 2, which the solution assumes as temp and light state, i substitute heat with light state in transition). but still stupid. my natural assumption was leds, even when i head incandascent bulbs in my house somewhere for nearly half of my life. it is also stupid, because when you allow me to do something i was mentioned in question to do, i could just bend my way to do anything. like punch/drill through wall, or hack surveillance systems, or just pull out my handy multimeter that i always have on me, open switch box and see which switch is live, which is dead, or see voltage/current/wattage change across the loop, or measure resistance and guess what thing is there, or like blackmail the interviewer to extract the answer.

[-] Pulptastic@midwest.social 6 points 6 days ago

You’re almost there. Turn the first one on for a while. Then then it off and turn the second one on and run to the room. There are theee possible scenarios. If the bulb is on, switch 2 controls it. If the bulb is hot but off switch 1 controls it. If the bulb is cold and off, switch 3 controls it.

[-] sga@piefed.social 5 points 6 days ago

i know this solution, but many problems are there, what if it is in a ceiling fixture, or enclosed in something such that i can not know the temp (hot or cold), then i can still observe luminosity changes. if you feel your eyes do a bad job, get a camera properly color and temp caliberated, and just focus on filament (now auto exposure or temperature adjustment).

tl:dr i am still trying to poke holes in this thermocol wall of defence.

load more comments (7 replies)
[-] Wirlocke@lemmy.blahaj.zone 11 points 6 days ago

Here's my answer that works with any kind of lightbulb.

Flip switch 1 on, switch 2 off, and get switch 3 stuck in a halfway point which I've done on both lever switches and flat switches.

If it's on it's switch 1, if it's off it's switch 2, if it's flickering or dimmed it's switch 3 and you should probably turn it off to stop damaging the relay.

[-] xthexder@l.sw0.com 9 points 6 days ago* (last edited 6 days ago)

Trying to get a switch stuck half way sounds like a good way to start a fire. If the bulb is dimmed, that means not all the power is making it to the bulb, and half of it is probably going into heating up the switch contacts. It could also be arcing inside the switch, which will also destroy the contacts. I think some new building codes require "arc fault protection" on circuits for this type of reason, in addition to "ground fault protection" (GFCI) on bathroom/kitchen circuits.

[-] mlg@lemmy.world 4 points 5 days ago

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.

[-] lengau@midwest.social 3 points 4 days ago

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..."

[-] JackiesFridge@lemmy.world 9 points 6 days ago

Literally ask someone which switch it is. Then ask them what idiot wired them up that way

[-] BCOVertigo@lemmy.world 9 points 6 days ago

I'd walk into the other room first and drop a mirror in the hallway on my way back so I could see lmao. My employer wouldn't want me touching a hot bulb since that might be a workplace hazard they'd be liable for after training me with stupid riddles.

[-] JackbyDev@programming.dev 6 points 6 days ago

Impossible even if you know if the light is on or off to start with. Even then, there are 2 possible outcomes which means the solution space halves on each test. 3 divided by 2 is greater than 1 (1.5) so we cannot figure it out in a single test.

That's my recollection of how to solve these from computer science. The classic one is 8 coins and figuring out which one weighs a different amount (and you don't know if it is more or less). You have a scale that tells you which side is heavier (or equal) but it doesn't give readouts (as in it doesn't say a side is X pounds/grams). With only three uses of the scale, how can you find the fake coin? I'm not going to go into the process in depth but because you have THREE outcomes (left heavier, equal, and right heavier) you reduce the solution space (which of the 8 coins is the bad one) by a THIRD each test. The number 8 sort of lures into thinking powers of 2. You can actually do it with 9 coins in 3 tests.

Some of the details of my explanation may be wrong, it's been over a decade since I took that class in college lol. It was my worst professor (while different story lol) but I distinctly remember him talking about this. He had a very thick accent, some form of eastern European or Russian, I'm not really sure what exactly. But he gave us that problem as homework or something or maybe just to think about. And he'd ask us to explain how we'd do it. Whenever someone began to describe something doing like test 4, 2, etc instead of the correct way (which involves using coins you already tested) he'd say "YOU'RE DOOMED!" Then someone else would try, and when they got to a way that wouldn't work "YOU'RE DOOMED!" It was hilarious. Very memorable.

[-] chaos@beehaw.org 6 points 6 days ago

Hint: the solution depends on a more realistic and physics-based model of the problem than you're using. And, even bigger hint, it's less intuitive now that light bulb technology has changed to become much more efficient, you should imagine this problem taking place with a '90s bulb.

load more comments (1 replies)
[-] Atlas_@lemmy.world 5 points 6 days ago

Also the number of outcomes isn't connected to the solution space reduction the way you say. If you don't know whether the fake coin is heavier or lighter, both tilt-right and tilt-left are effectively the same result. So at least your first test really only has 2 meaningful outcomes.

In general, you'll only reduce your solution space DOWN TO (not by) 1/(number of distinguishable outcomes) if the possible solutions are evenly divided among those outcomes. It's easy to have a problem where "result 1 narrows it down a lot, result 2 doesn't tell us much"

load more comments (1 replies)
load more comments (2 replies)
[-] rumba@lemmy.zip 3 points 6 days ago* (last edited 6 days ago)

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.

  1. ask an occupant

  2. shove a penny in the socket behind the light bulb and listen for a breaker to pop

  3. turn all three on

  4. slide your cell phone under the door with video recording on, stomp on the floor hard every time you flip a switch

  5. turn all the switches through a binary counter looking for one that seems to do nothing.

load more comments
view more: next ›
this post was submitted on 25 Dec 2025
554 points (96.9% liked)

Programmer Humor

28137 readers
1128 users here now

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

founded 2 years ago
MODERATORS