BasketMC

Signal Window Filter, Episode 13: TIS-100

  • Published on

Episode 13 opens Signal Window Filter, a puzzle that wants two running sums out of one stream of numbers. Basket starts with a plan built on the stack memory nodes, scraps it, borrows from an older puzzle, and gets every test to pass in the last minute of play.

Two sums from one stream

The task panel reads: "Read values from IN. Write the sum of the last 3 values to OUT.3 and the sum of the last 5 values to OUT.5. Assume prior IN values are 0." The board has two stack memory nodes down the right side and a red node marked "Communication failure" in the top left corner.

The commentary sees the problem straight away: it needs to keep track of five values for one output and three for the other, as a rolling total. The stacks look like the place to keep them.

TIS-100 Signal Window Filter puzzle with every node empty: the task panel asks for the sum of the last 3 values on OUT.3 and the last 5 on OUT.5, beside the IN, OUT.3 and OUT.5 columns, two stack memory nodes on the right and a red communication failure node at top left.

Priming the stacks

The first attempt fills the stacks with zeros so they never start empty. One node gets "MOV 0 RIGHT" twice before its loop, and the node between the two stacks gets four "MOV 0 DOWN" lines, then "MOV LEFT NIL" to wait for a signal. A quick test checks what a node does when it reads from an empty stack: "So I think this never triggers."

The trouble is the order. The commentary needs to add the stored values together but keep the last ones, and then put them back "in the correct order." No way of doing that turns up. "I'm gonna keep this program and then start over." The segment map later shows that attempt saved as a second program, not yet solved.

TIS-100 editor in Signal Window Filter: a top node starts with MOV 0 RIGHT twice before its loop, and the node between the two stack memory nodes on the right starts with four MOV 0 DOWN lines, then MOV LEFT NIL and MOV UP ACC.

A look back

Before starting again, Basket clicks the red node. A "Compute node diagnostic" box opens, and its last line reads "Its memory still contains the last thing it saw." The commentary had wondered whether the arrows pointing into that node meant it would do something if passed a value, and is left unsure what the message means. Without that node in the way, the commentary says, the layout would be a little easier.

Then Basket opens Sequence Counter to see how sums were done there, and brings back a loop of "SAV", "SWP" and "ADD UP". Around the 17-minute mark the commentary signs off for the episode, then comes straight back with "Welcome back" on the same board. Both sessions are in this one video.

A chain of nodes

The new plan passes each value along a chain. Every node saves the value it holds, adds in the value from its neighbor, sends the sum on, swaps the value back, and passes it to the next node. "This may or may not work at all."

The first run gets the first two OUT.3 values right, 11 and 88, and then stops. OUT.5 shows a 0 in red. "We actually got three right, that's cool." The commentary goes node by node, reading where each one is stuck, and finds that two values need to pass through each other.

TIS-100 running test 1 of Signal Window Filter with eight nodes of code: OUT.3 has received 11 and 88, the first OUT.5 value shows 0 in red, and the nodes sit waiting on reads and writes with question marks on their arrows.

Sending it twice

The answer is that the sum for OUT.3 has to go two ways. The center node gets a new line, "MOV RIGHT DOWN", to throw the three-value sum straight down, and the node below changes to "MOV UP DOWN" to pass it on to OUT.3. The same sum still goes left to build the five-value one. "Not too shabby."

Tests 1, 2 and 3 pass in 663 cycles each, and the random test passes too.

TIS-100 Signal Window Filter running on fast: the panel reads test 1, 2 and 3 passed in 663 cycles and running random test, and the OUT.3 and OUT.5 columns match the expected values down the list.

Where it ends

The result screen reads 663 cycles, 8 nodes and 31 instructions, and the comparison boxes beside it are empty this time. The commentary notes it took less time than expected. The segment map shows Signal Window Filter as nominal, with Signal Divider next on the row, and the video cuts to the end card.