四个开关找灯泡
Light Switches
题目详情
房间里有一只灯泡,屋外有 4 个开关,只有其中 1 个控制灯泡。
你可以在进屋前随意开关任意开关任意次。但一旦打开门进屋查看,就不能再出去调整开关。
问:最少需要进屋几次,才能确定哪个开关控制灯泡?
There is a light bulb in a room and four switches outside, only one of which controls the light. You can turn any switches on/off any number of times you want, but once you open the door and go inside to check, you cannot change the switches anymore. How many times do you need to enter the room to know for sure which switch controls the bulb?
解析
只需要进屋 1 次。
利用“灯泡会发热”作为额外信息:
- 打开开关 1 一段时间后关掉;
- 打开开关 2 不等待;
- 保持开关 3、4 关闭,立刻进屋。
判断:
- 若灯泡亮:开关 2。
- 若灯泡不亮但温热:开关 1。
- 若灯泡不亮且冰凉:开关 3 或 4(此时可通过在进屋前对 3/4 再做一次不同的“等待/不等待”安排来区分,保证一次进屋足够)。
Original Explanation
You only need 1 entry. Use the bulb’s heat as extra information:
- Turn on switch #1 and #2 for some time (long enough to heat the bulb if #1 or #2 is correct).
- Turn off #2, turn on #3, leave #4 off. Enter the room:
- If the bulb is on (and hot or cold), it is switch #3.
- If the bulb is off but hot, it is switch #1.
- If the bulb is off and cold, it is switch #4 (or #2 if you swapped the exact roles; typically one deduces carefully).
A common simpler version is 3 switches, but with 4 you can adapt similarly.