WORM Solution

CRUNCHER

WORM row 9

In-game screenshot of CRUNCHER
In-game view
FamilyWORM Graph0.817 Difficulty0.817 Ring05 IDw43

Prerequisites

GRAY WALK

Unlocks

PHASE BURST

Reference rack program w43 solved
Active cores1, 4, 5, 7 Program lines34 DetailWORM row 9

Walkthrough

CRUNCHER: run-length ENCODE: each run of equal values -> (value, count).

Straight down column 0 (input core 0 -> output core 8), DELAY hangs off core 4.

c0 READER : forward the 13 inputs DOWN to c4, then a 0 end sentinel, then idle.

c5 DELAY : 1-deep store; returns the PREVIOUS element TWICE so c4 can both

compare against it and forward it as the ended run's value.

c4 DETECT : next-prev; equal -> send a 0 "same" tick DOWN to c8; differ -> send

the previous element (the ended run's value) DOWN to c8.

(first element: prev seed 0 -> a 0 tick, counted as run[0]'s first.)

c8 COUNT+OUT: a 0 tick grows the run length; a nonzero token v means a run of

value v ended -> write v then its length to output 0, reset len=1.

Rack Solution
# CRUNCHER: run-length ENCODE: each run of equal values -> (value, count).
# Straight down column 0 (input core 0 -> output core 8), DELAY hangs off core 4.
#   c0 READER : forward the 13 inputs DOWN to c4, then a 0 end sentinel, then idle.
#   c5 DELAY  : 1-deep store; returns the PREVIOUS element TWICE so c4 can both
#               compare against it and forward it as the ended run's value.
#   c4 DETECT : next-prev; equal -> send a 0 "same" tick DOWN to c8; differ -> send
#               the previous element (the ended run's value) DOWN to c8.
#               (first element: prev seed 0 -> a 0 tick, counted as run[0]'s first.)
#   c8 COUNT+OUT: a 0 tick grows the run length; a nonzero token v means a run of
#               value v ended -> write v then its length to output 0, reset len=1.
@1
MOV ACC, 13
L: MOV DOWN, UP
SUB 1
JNZ L
MOV DOWN, 0
E: JMP E
@5
L: MOV ACC, LEFT
XCH
MOV LEFT, ACC
MOV LEFT, ACC
JMP L
@4
L: MOV ACC, UP
MOV RIGHT, ACC
SUB RIGHT
JZ S
MOV DOWN, RIGHT
JMP L
S: MOV NIL, RIGHT
MOV DOWN, 0
JMP L
@7
L: SAV
MOV ACC, UP
JNZ B
XCH
ADD 1
JMP L
B: MOV DOWN, ACC
XCH
MOV DOWN, ACC
MOV ACC, 1