Toggle lamps by parity

Logical thinking · Suggested grades 4

Toggle lamps by parity

Download video
Open Chinese transcript
  1. 三盏灯开始全灭。开关A切换1、2号,B切换2、3号;切换就是亮变灭、灭变亮。
  2. 先按A,1号和2号各切换一次,状态变成亮、亮、灭。
  3. 再按B,2号从亮变灭,3号从灭变亮,1号不动。
  4. 最终是1号亮、2号灭、3号亮。按次数看,1和3各一次,2号两次复原。
  5. 直接模拟与奇偶检查得到同一结果,能防止漏掉2号的第二次变化。
  6. 现在从全灭开始,先按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

Starting off, press A then B. Which lamps are on?