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

Programmer Humor

28043 readers
427 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!

you are viewing a single comment's thread
view the rest of the comments
[–] 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.