Skip to content

“TIS-100” – SEQUENCE SORTER (SEGMENT 63534)

TIS-100 index

Here’s an implementation of selection sort that almost but doesn’t quite work, because it’s one line too short:

full incorrect solution

The upper left unit reads in the sequence and stores it in the upper stack memory node, alerting the rest of the program when it’s done. The unit below the stack then reads every number in the sequence, passing them left to the other stack memory node and right to two nodes that keep track of the minimum value of the sequence.

After it’s passed through the whole sequence, it sends a signal down to the unit right below the output, which then rereads the sequence from the lower stack, comparing each of them with the minimum value that was found. For every element except the minimum, it just passes it back up, but when it finds the minimum, it outputs it and removes it from the sequence. The program then repeats selecting the minimum element from that reduced list until it’s sorted.

When the list has no more elements, then the first item that unit below the upper stack memory node will read is 0, which is its cue to signal the unit below it to send out a 0 to finish the sequence and the input unit to restart.

The problem is that unit doesn’t have enough code space to send out both of those signals, so that’s why this doesn’t work.

I’ve spent a few frustrating hours trying to cut out an extra line of code to no avail, and I’m now completely uninterested in trying to fix this. I’ve solved the puzzle to my satisfaction, just not the game’s.