this post was submitted on 25 Dec 2025
244 points (97.3% liked)

Programmer Humor

39640 readers
566 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 6 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!

you are viewing a single comment's thread
view the rest of the comments
[–] Dudewitbow@lemmy.zip 18 points 4 days ago* (last edited 4 days ago) (3 children)

if anyoen is curous on the answer, you flip one and wait till you think a light bulb gets warm enough from ambient that youd notice. you then turn that off and turn another on.

if light = on, second switch you hit

if light = off && bulb = warm, it was the first switch

else switch 3

[–] RedCarCastle@aussie.zone 11 points 4 days ago (1 children)

Doesn't say I can't leave the door open of the room with a light, or just put someone else in the room while I flick the switchs, use a few mirrors to bounce the light back to me,

[–] Dudewitbow@lemmy.zip 4 points 4 days ago* (last edited 4 days ago) (1 children)

of course, nothing says you can't but programming (and engineering) is not just solving the problem, but solving the problem efficiently.

one who lacks optimization knowledge would run into situations like the rockstar employee who originally wrote the parser for GTAO that made it take over 5 minutes to load GTAO, till someone else rewrote the parser in order to get people loaded in quicker. It's basically the weed out for the devs people complain about when something uses way more resources than it needs to.

[–] RedCarCastle@aussie.zone 4 points 4 days ago

I was confused why you had brought programming into it but I realised where I was lol I could always take the light out, can't waste resources on something that doesn't exist

[–] Decq@lemmy.world 5 points 3 days ago* (last edited 3 days ago)

That's not the answer. It's an answer. The question isn't very contained so there are a lot of answers. You can get someone else to switch the switches in order while you watch. Or you can install a camera in the room and then pull the switches. You can keep the door open to see which switches works, etc. Probably a million more solutions.

[–] tias@discuss.tchncs.de 4 points 4 days ago (1 children)

This assumes that the light was off from the start but the question doesn't specify that.

[–] Dudewitbow@lemmy.zip 2 points 3 days ago (1 children)

if you want to avoid that problem, you would just add the step at the very start: have all the bulbs in off and wait a bit for all the bulbs to cool off if you needed to be sure.

[–] tias@discuss.tchncs.de 4 points 3 days ago (1 children)

wdym "have all the bulbs in off". You can't verify that without looking into the room and then you've burnt your one shot.

[–] Dudewitbow@lemmy.zip 0 points 3 days ago* (last edited 3 days ago) (1 children)

you get to the point where no question can ever be asaked to you because you believe in the manipulation of the question over to the point that you're intentionally looking for ways to break the question rather than assuming you and the question giver has the same assumption given the question circumstance.

If you go out and look for dumb things like that, there is basically no question in the universe thats answerable.

Do you question if gravity and friction exist if someone asks you how fast something is moving? and what values they are?

[–] Tlaloc_Temporal@lemmy.ca 1 points 3 days ago (1 children)

We can check that gravity and friction exists right now, without leaving the room. It's also quite specific situations that don't have either one.

Here, how the switches are related to the light is already in question, and dumb wiring jobs are more common than anyone wants.

[–] Dudewitbow@lemmy.zip 1 points 3 days ago* (last edited 3 days ago)

but you dont know the values to which they are to br able to ask a question involving it which is the point. youre put in a situation where you dont know everything. there are things you assume the question giver assumes else questions are never answerable. they arent given to you as a gotcha situation, especially in the context as a programming question.