Episode 2
The Missing Boot
A duck is about to start packing his suitcase for a puddle parade. The green light on the suitcase indicates that he is ready to go, but one boot is missing.






















Episode transcript
Scene 1: Wait for me!
The duck hears the puddle parade. He turns to see what's going on. The duck rushes for his suitcase. The robot in the workshop sees the duck on the monitor.
The duck opens his suitcase in preparation for the puddle parade. He looks inside. In the left slot he sees a red boot. The right slot is empty. The light for packing is green.
His wing brushes the bottom of the empty slot.
Only one boot remains in the left slot.
Scene 2: The light's not stuck.
He pulls the one boot out of the left slot. Both slots are now empty. The light goes out.
The duck inserts that one (and only) boot into the right slot. The light goes green.
The duck takes that boot out of the right slot and puts it in the left slot. The right slot is now empty and the left slot is the only one with a boot in it. The lamp is green again.
The rule is: LEFT OR RIGHT. When the left slot is filled with a boot, the light will be on.
Scene 3: That's what I wanted.
The robot flips it to the LEFT AND RIGHT rule. He keeps the one boot in the left slot. The other slot is empty. So the light turns off.
Duck tries out AND by shifting one boot to the right slot of the suitcase. The light does not come on. Just the right boot is there. The left is empty.
The duck grabs the boot and moves it from the right slot to the left slot in the suitcase. The right slot is now empty again and the light stays off. Then the duck notices the second red boot next to the suitcase.
The duck is holding the other red boot over the right slot (empty) of the suitcase. The light is off, and the duck pauses.
The duck stuffs the other red boot in the right slot. The light goes green.
Duck pulls the boot out of the left slot to test the rule. The boot in the right slot stays in. The left slot is now empty. The light turns off.
He puts the boot in the left slot of the suitcase. He already has a boot in the right slot. Now both boots are in their slots. The light goes green.
Scene 4: OK, so it's puddle time.
The duck is getting the red boots out of the two slots in his suitcase. When there's nothing in the slots the AND light goes out.
The duck stares at both red boots before he jumps into the puddle.
Duck splashes through the puddle parade.
Why the light was wrong
The two boot slots provide "true" or "false" answers to the program, separately.
OR means that if one or both answers are yes, turn on the light. AND means if both answers are yes, turn on the light.
Try all four combinations
Open MDN Playground (opens in a new tab). Add this code to the JavaScript pane. Run the example. Inspect the 4 rows in the console.
const slots = [[false, false], [true, false], [false, true], [true, true]];
for (const [leftBoot, rightBoot] of slots) {
const orLight = leftBoot || rightBoot;
const andLight = leftBoot && rightBoot;
console.log('Left:', leftBoot, 'Right:', rightBoot, 'OR:', orLight, 'AND:', andLight);
}The only time the two rules give different results is if there's exactly one slot filled.
Your turn
A toy lamp needs to switch on only when the switch is on and the plug is in. The switch is on, but the plug is not plugged in. What's the rule? Should the lamp turn on or not?
Answer
The lamp doesn't light. The rule for the lamp is that the switch is on AND the plug is in.