Episode 16 stays on Sequence Indexer, the segment Episode 15 started, and on its main problem: the stack memory node hands numbers back in the opposite order. Basket tries pouring one stack into the other to turn the order around, then adds a signal so the lookup waits. The puzzle is still unsolved when the video ends.
A failing run to start
The segment's text reads: "Sequences are zero-terminated. Read a sequence from IN.V. Read index values from IN.X. Look up index value in sequence. Write indexed value to OUT." IN.V feeds the top left node, IN.X the top of the third column, and OUT leaves from the bottom of the third column. Both stack memory nodes sit in the middle column.
The video opens on a run of the old program. OUT expects 860 first and gets a red 697. "Okay, I might have an idea." Basket moves the lookup code to another node and talks through pulling values off a stack and putting them back, then drops it: "Then I'll just keep on getting the same thing back." After "Okay, I will be back again," the video cuts.
Pouring one stack into the other
The new plan: "I'm going to move everything over to here, and I think it will reverse the order." The top left node fills the top stack, then switches to "L: MOV RIGHT DOWN" and "JMP L" to empty it. "MOV UP DOWN" and "MOV UP RIGHT" in the left column carry the values into the bottom stack. The center node does the lookup with L1 and L2 loops, a DONTSEND label and "SUB 1".
Stepping through, the top stack fills "sort of in the reverse order that we want," and then values start to land in the bottom stack.
Too early
Watching the center node, the commentary sees it grab a value before the move is done: "I guess I have to wait till the whole stack moves before I look at it." The left nodes get "MOV -1 RIGHT" and "MOV -1 UP" as a ready signal ("I'll do negative one just so I can make sure I see it"), and the center node gets "MOV LEFT NIL" so it holds until the signal arrives. The next run brings "Wait, what?" and then "Oh, the zero."
Where the zero goes
The rest of the video goes into the zero that ends each sequence. "Do I want the zero at the beginning or the end? It kind of needs to be both." The bottom left node is rewritten to preload a zero with "MOV 0 RIGHT", stop on a zero with "JEZ GO", and send "MOV -1 UP" under a GO label.
Where it ends
No test passes in this episode. The last thing on the recording is a plan for one more signal, "a signal coming down to say, start moving stuff," and the video cuts to the end card with the code still being written.