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

Programmer Humor

30835 readers
1213 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!

(page 3) 50 comments
sorted by: hot top controversial new old
[–] MonkderVierte@lemmy.zip 2 points 3 months ago* (last edited 3 months ago)

Disassemble the switch and look what's connected.

[–] Digit@lemmy.wtf 2 points 3 months 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.

[–] Kolanaki@pawb.social 2 points 3 months ago (1 children)

I'm just flipping all 3 switches and the light can stay on forever. 🤷‍♂️

[–] cm0002@mander.xyz 1 points 3 months ago

Why that's executive material!

[–] backgroundcow@lemmy.world 2 points 3 months ago* (last edited 3 months 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.

[–] kubica@fedia.io 1 points 3 months ago

Thinking skills, why would those be needed?

[–] Bluewing@lemmy.world 1 points 3 months ago (5 children)

If the installation of the circuit was done correctly in the first place, all 3 switches will turn the light on and off.

If they do not, there is a problem and it needs to be fixed. If you don't fix the issue, you have a major underlying problem in your company. And you are not worth my time.

load more comments (5 replies)
[–] saturn57@lemmy.world 1 points 3 months ago (1 children)

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 3 months 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

load more comments
view more: ‹ prev next ›