562

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
[-] saturn57@lemmy.world 1 points 1 day ago

The "right" solution doesn't work. Each light switch can turn the lightbulb on by being up or being down. This means there is 3*2=6 possible cases of which light switch state turns on the light bulb. So we need to make 3 observations to bring it down to one case. An example of the original logic failing is that the light bulb being on could mean either that switch 2 being up turns it on, switch 1 being down turns it on, or switch 3 being down turn it on.

I present an alternative solution. Since the conventional solution says that we can feel its temperature, we know the light bulb is within reach. We can visit the room first, unplug the light bulb, and bring it back to the light switches. Then we can check all 2^3 permutations of light switches to see which one effects the bulb. Of course, it is likely that non affects it after unplugging it, but it could be a wireless light bulb.

[-] Digit@lemmy.wtf 1 points 1 day ago

What if the light's on with a combination of different positions spanning 2 or all of the switches? How many possibilities then? Plus the possibility none of these switches have anything to do with that light, and the original question had a fallacious premise. Then even the possibility that the light has different states from different combinations... and/or that the light functions differently at different times, and/or different combinations of other criteria. How many possibilities do we have now? ... I can't be bothered doing the maths. I gotta get breakfast. n_n

[-] Digit@lemmy.wtf 2 points 3 days ago

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.

[-] otacon239@lemmy.world 196 points 1 week ago

For those that want the actual answer:

Tap for spoilerYou 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.

[-] NaibofTabr@infosec.pub 244 points 1 week ago

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.

[-] partial_accumen@lemmy.world 150 points 1 week ago

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".
[-] db2@lemmy.world 22 points 1 week ago

Also the image shows all 3 switches are on.

[-] SmoothLiquidation@lemmy.world 46 points 1 week ago

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.

[-] NaibofTabr@infosec.pub 19 points 1 week ago* (last edited 1 week ago)

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.

[-] taiyang@lemmy.world 14 points 1 week ago

I love the idea of someone trying this stupid question irl only to realize it wasn't even plugged in. That's ... well fuck, that's most IT work. The convoluted approach is definitely the wrong one. Lol

load more comments (2 replies)
[-] yaroto98@lemmy.world 90 points 1 week ago* (last edited 1 week ago)

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.

[-] Digit@lemmy.wtf 2 points 3 days ago

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.

[-] Oka@sopuli.xyz 56 points 1 week ago* (last edited 1 week ago)

This also assumes youre alone, a practical person would send someone else in the other room and communicate the states back

load more comments (1 replies)
load more comments (1 replies)
[-] Ilovethebomb@sh.itjust.works 62 points 1 week ago

You'd be boned if it's an LED bulb that doesn't warm up noticeably.

[-] Nighed@feddit.uk 16 points 1 week ago

Or if it was turned on to begin with and you just turned it off

[-] Pissmidget@lemmy.world 36 points 1 week ago

tap for comment to spoilerNice try, they recently upgraded to led lights.

[-] snooggums@piefed.world 22 points 1 week ago

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.

load more comments (1 replies)
[-] count_dongulus@lemmy.world 146 points 1 week ago* (last edited 1 week ago)

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.

[-] Digit@lemmy.wtf 1 points 3 days ago

pull the cables

LOL.

the walls are glass

Or use psychic powers. XD

[-] 4am@lemmy.zip 21 points 1 week ago

Their bases do, quite famously. Especially the smart ones.

[-] 18107@aussie.zone 38 points 1 week ago

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.

[-] Dekkia@this.doesnotcut.it 17 points 1 week ago

I fully agree with your rant.

But LED bulbs do get warm enough that this still would work.

[-] drosophila 22 points 1 week ago

Philips Ultra Efficient bulbs use only 4 watts, and they have a glass bulb and metal base, so they might feel cool to the touch anyway. Or at least feel plausibly the same temperature as the room, depending on how hot it is in there.

load more comments (1 replies)
load more comments (2 replies)
[-] hperrin@lemmy.ca 97 points 1 week ago

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.

[-] Digit@lemmy.wtf 1 points 3 days ago

take a picture

I think you mean have a live video feed.

Otherwise, decent answer.

[-] kinkles@sh.itjust.works 50 points 1 week ago

Answer:

Tap for spoilerFlip 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.

[-] SkyezOpen@lemmy.world 23 points 1 week ago

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.

load more comments (1 replies)
[-] quinkin@lemmy.world 43 points 1 week ago

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

Lockout both rooms and log a job with maintenance.

[-] ilinamorato@lemmy.world 42 points 1 week ago* (last edited 1 week ago)

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.

load more comments (1 replies)
[-] gustofwind@lemmy.world 39 points 1 week ago

The answer isn’t intuitive anymore now that lightbulbs don’t always get hot 🥲

[-] Ledivin@lemmy.world 32 points 1 week ago* (last edited 1 week ago)

It wasn't intuitive before, either, without making an absolute ton of horrible assumptions.

  • Are the wires even connected?
  • Does only one switch control the light?
  • Did the light start on or off?
  • Is the light bulb in arm's reach?
  • Can I bring my friend and just yell to each other?
  • Can I just leave the door open and see whether it turns on or not?
  • It says I'm allowed to visit the bulb room once but never actually mentions the switch room - do I start there? Can I go back after visiting the bulb room?
  • And, as you said, what type of bulb is it?

Anyone who doesn't explore the assumptions should probably fail that particular interview question.

load more comments (4 replies)
[-] stray@pawb.social 37 points 1 week ago

I don't understand. You don't need to visit a room to know whether the light is on in it.

[-] victorz@lemmy.world 23 points 1 week ago

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.

[-] fartographer@lemmy.world 31 points 1 week 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.

[-] usernamefactory@lemmy.ca 24 points 1 week 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.

[-] Cevilia 21 points 1 week ago* (last edited 1 week ago)

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.

[-] NaibofTabr@infosec.pub 21 points 1 week ago* (last edited 1 week ago)

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

[-] reddit_sux@lemmy.world 19 points 1 week 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)
[-] MonkderVierte@lemmy.zip 16 points 1 week ago

This is either a really clever test of your problem solving and neccessary-information-extraction skills. Or a really dumb one with loads of asumptions and artifical restrictions and based on outdated data (comments hint to the lightbulb getting hot).

[-] SCmSTR 15 points 1 week 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 11 points 1 week 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!

[-] MNByChoice@midwest.social 15 points 1 week ago

Building codes, at least the ones I am aware of, require the light switch inside the room with the light next to the door, similar to how nearly every room you have ever been in. (Everyone knows of exceptions.) This means either corners have been cut, at those switches should control things within the room with the switches.

As the interviewer if attention to detail and following build codes and specifications is important at this company. Is there a culture of safety, or are corners cut that put my life at risk.

[-] umbraroze@slrpnk.net 15 points 1 week 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

[-] aarch64@programming.dev 15 points 1 week ago

My burn-the-house-down take on this: very slowly flip each switch on and listen for arcing. Works fine assuming the other two switches aren't connected to anything.

[-] _druid@sh.itjust.works 15 points 1 week ago

Take the cover off, flip all three switches. Whichever terminal shocks you is completing the circuit for the light.

load more comments (2 replies)
[-] sga@piefed.social 14 points 1 week 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.

load more comments (9 replies)
[-] Modern_medicine_isnt@lemmy.world 14 points 1 week 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.

[-] strlcpy@lemmy.sdf.org 13 points 1 week 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 14 points 1 week 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.

[-] Wirlocke 11 points 1 week 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.

load more comments (1 replies)
load more comments
view more: next ›
this post was submitted on 25 Dec 2025
562 points (100.0% liked)

Programmer Humor

28241 readers
946 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