Skip to content

“TIS-100” – SEQUENCE INDEXER (SEGMENT 62711)

TIS-100 index

full solution

The program begins on the left side, where the upper left unit reads in the whole sequence and crams it into the upper stack memory unit with a sentinel of -1 at the beginning. When it’s done, it sends a signal down to begin the process of repeatedly indexing into the sequence.

flipper code segment

The flipper unit in between the two stack memory units repeatedly transfers the sequence from one unit to the other, sending a copy of every value to the selector unit to its right.

selector code segment

The selector unit reads in an index from up and then pulls in each of the values the flipper unit sends it, sending the indexth one down to the output and throwing away the rest.

There’s one tricky bit here: because the flipper unit is transferring the list between stacks, every time it transfers the list downward, it will pass values to the selector unit in reverse order! So before the selector unit gets an index, the unit above it that reads from input calculates its inverse, (9 – index) for a list of 10 values, every other time.

You may have noticed that the program assumes that there are 10 values in the sequence. There are enough free lines of code available that it’d be possible to modify the program to handle sequences of varying length by having the sequence reader count how many values it reads in and then passing the count around to the index reader before it begins.