this post was submitted on 25 Dec 2025
543 points (96.9% liked)

Programmer Humor

28045 readers
433 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
 

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
[–] Stupidmanager@lemmy.world 4 points 15 hours 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.

[–] mlg@lemmy.world 2 points 15 hours 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.

[–] quinkin@lemmy.world 41 points 1 day ago

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

Lockout both rooms and log a job with maintenance.

[–] strlcpy@lemmy.sdf.org 13 points 1 day ago (1 children)

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 13 points 1 day 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.

[–] reddit_sux@lemmy.world 20 points 1 day ago (1 children)

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.

[–] Socialism_Everyday@reddthat.com 0 points 13 hours ago (1 children)

Remove the switches put a microcontroller like esp32

ESP32 proceeds to explode with 230VAC

[–] reddit_sux@lemmy.world 1 points 9 hours ago* (last edited 9 hours ago)

Don't worry I power it with a Chinese adapter nothing of blowing up happens here. Also I have an app for it.

[–] usernamefactory@lemmy.ca 25 points 1 day 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.

[–] captain_aggravated@sh.itjust.works 56 points 1 day ago (6 children)

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?

[–] pyre@lemmy.world 8 points 1 day 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.

[–] vivalapivo@lemmy.today 5 points 1 day 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

[–] mojofrododojo@lemmy.world 13 points 1 day ago (3 children)

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 1 day ago

The image does depict an incandescent filament bulb.

[–] Dremor@lemmy.world 4 points 1 day ago* (last edited 1 day ago) (3 children)

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 1 day 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

[–] mojofrododojo@lemmy.world 1 points 16 hours ago

note the premise specifies HOT.

none of my LED bulbs get hot even after hours. they do warm up from 'cold' but HOT?

ymmv.

[–] Zacryon@feddit.org 2 points 1 day ago

but enough for that answer to be valid

Highly arguable. Especially without specifications on the lamp. It could be a rather dim and small one. Then, you either need special equipment or supersenses.

[–] luciferofastora@feddit.org 3 points 1 day ago (1 children)

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

[–] mojofrododojo@lemmy.world 1 points 16 hours ago

yeah silly games for bored hiring managers

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

load more comments (2 replies)
[–] SCmSTR@lemmy.blahaj.zone 14 points 1 day ago (1 children)

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!

[–] rumba@lemmy.zip 3 points 1 day ago* (last edited 1 day 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.

[–] fartographer@lemmy.world 32 points 1 day 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.

[–] ilinamorato@lemmy.world 41 points 1 day ago* (last edited 1 day ago) (1 children)

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.

[–] Natanael@infosec.pub 2 points 1 day ago

"why was I not equipped with current detectors as that is standard practice in the industry?"

[–] otacon239@lemmy.world 195 points 2 days ago (6 children)

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 242 points 2 days ago (6 children)

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 146 points 2 days ago (2 children)

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".
[–] TeamAssimilation@infosec.pub 45 points 2 days ago (3 children)

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.

load more comments (3 replies)
load more comments (1 replies)
load more comments (5 replies)
[–] yaroto98@lemmy.world 93 points 2 days ago* (last edited 2 days ago) (3 children)

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.

[–] RickyRigatoni@retrolemmy.com 2 points 1 day ago

Don't even need to leave the door open. What door doesn't have enough of a gap to see if a light is on?

load more comments (2 replies)
[–] Ilovethebomb@sh.itjust.works 61 points 2 days ago (2 children)

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

load more comments (2 replies)
load more comments (3 replies)
[–] hperrin@lemmy.ca 99 points 2 days 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.

[–] count_dongulus@lemmy.world 145 points 2 days ago* (last edited 2 days ago) (13 children)

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.

load more comments (13 replies)
[–] Wirlocke@lemmy.blahaj.zone 11 points 1 day ago (1 children)

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 1 day ago* (last edited 1 day 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.

[–] janus2@lemmy.zip 64 points 2 days ago

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

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.

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

[–] GreenKnight23@lemmy.world 23 points 2 days ago (1 children)

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%?

load more comments (1 replies)
[–] stray@pawb.social 36 points 2 days ago (1 children)

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

load more comments (1 replies)
[–] sga@piefed.social 14 points 1 day ago (9 children)

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)
load more comments
view more: next ›