easy | general |
There is a light bulb inside a room and three switches outside. All switches are currently in off state and only one switch controls the light bulb. You may turn any number of switches on or off any number of times you want. How many times do you need to go into the room to figure out which switch controls the light bulb?
A lighted bulb also emits heat and gets hot slowly (not instantaneously!)
1
The bulb gets hot slowly when turned on. Turn on the switch # for 10 minutes, turn it off and turn on the switch # and get into the room. There are possible cases.
- If the bulb is on, then switch # controls the bulb.
- If the bulb is off, but hot, then switch # controls the bulb.
- If the bulb is off and cool, then switch # controls the bulb.
Thus, we can infer the switch that controls the bulb in one entry.
Follow up question
What if there were switches?
Follow up answer
Assuming that modern bulbs heat up slowly, we can infer this in one entry. Turn on the switch # and # keeping others off. Wait for 10 minutes. Turn off #, turn on #, and quickly enter the room. Following are the possible states and the corresponding switch that controls the bulb.
State | Inferred Switch | |
---|---|---|
on and hot | 1 | |
off but hot | 2 | |
on but cool | 3 | |
off and cool | 4 |
The following table shows this information in a grid format:
On | Off | |
---|---|---|
Hot | 1 | 2 |
Cold | 3 | 4 |