WORM Solution

ABS DIFFERENCE

WORM row 6

In-game screenshot of ABS DIFFERENCE
In-game view
FamilyWORM Graph0.555 Difficulty0.555 Ring04 IDw56

Prerequisites

XOR TEETH

Unlocks

Alternating Lock

Reference rack program w56 solved
Active cores0, 1, 2, 3, 4 Program lines17 DetailWORM row 6

Walkthrough

ABS DIFFERENCE: OUT = |A: B|. A is the top-left tap, B the top-right tap.

Two-row rack: A rides core 0 (UP), B rides core 2 (UP), output rides core 4

(DOWN, the bottom-middle tap).

core 2 forward B LEFT toward the compare core.

core 1 relay B LEFT into core 0 (split so the link->link hop is stable).

core 0 ACC = A (UP); SUB B (RIGHT, the relayed copy). If the difference is

positive it is already the magnitude; otherwise NEG flips it (0 stays

0). Emit DOWN to core 3.

core 3 relay the result RIGHT into core 4.

core 4 emit the magnitude DOWN to the output tap.

Rack Solution
# ABS DIFFERENCE: OUT = |A: B|. A is the top-left tap, B the top-right tap.
# Two-row rack: A rides core 0 (UP), B rides core 2 (UP), output rides core 4
# (DOWN, the bottom-middle tap).
# core 2  forward B LEFT toward the compare core.
# core 1  relay B LEFT into core 0 (split so the link->link hop is stable).
# core 0  ACC = A (UP); SUB B (RIGHT, the relayed copy). If the difference is
#         positive it is already the magnitude; otherwise NEG flips it (0 stays
#         0). Emit DOWN to core 3.
# core 3  relay the result RIGHT into core 4.
# core 4  emit the magnitude DOWN to the output tap.
@2
MOV ACC, UP
MOV LEFT, ACC
@1
MOV ACC, RIGHT
MOV LEFT, ACC
@0
MOV ACC, UP
SUB RIGHT
JG P
NEG
P: MOV DOWN, ACC
@3
MOV ACC, UP
MOV RIGHT, ACC
@4
MOV DOWN, LEFT