Toggle lamps by parity
Toggle lamps by parity
The video could not load. Check your connection and try again, or download it directly.
Download video
Open Chinese transcript
- 三盏灯开始全灭。开关A切换1、2号,B切换2、3号;切换就是亮变灭、灭变亮。
- 先按A,1号和2号各切换一次,状态变成亮、亮、灭。
- 再按B,2号从亮变灭,3号从灭变亮,1号不动。
- 最终是1号亮、2号灭、3号亮。按次数看,1和3各一次,2号两次复原。
- 直接模拟与奇偶检查得到同一结果,能防止漏掉2号的第二次变化。
- 现在从全灭开始,先按B再按A。请逐盏翻状态并说出最终结果,小宝贝到你了。
Sources for this explanation
Logical thinking
Simulate each toggle and independently check the parity of toggles per lamp.
Worked example
Three lamps start off. A toggles lamps 1 and 2; B toggles 2 and 3. Press A then B. Which are on?
Lamp 1 toggles once, lamp 2 twice and lamp 3 once, so lamps 1 and 3 are on.
Try one question
1 and 3 toggle once; 2 toggles twice back to off.