WORM Solution

CHECK DIGIT

WORM row 10

In-game screenshot of CHECK DIGIT
In-game view
FamilyWORM Graph0.910 Difficulty0.910 Ring05 IDw48

Prerequisites

Polynomial License

Unlocks

TWO PHASE WAIT

Reference rack program w48 solved
Active cores1, 4, 7 Program lines28 DetailWORM row 10

Walkthrough

CHECK DIGIT: 4-digit frames d0..d3; s = 4d0+3d1+2d2+d3; out d=(-s) mod 11 in 0..10.

core 0 streams the 4 running prefix sums (their total is s).

core 4 sums -> s, coarse-reduces mod 33 (a multiple of 11), ships the remainder down.

core 8 fine-reduces mod 11 and maps to d = 11-r (0 when r==0), emits. Loops pipeline.

Rack Solution
# CHECK DIGIT: 4-digit frames d0..d3; s = 4d0+3d1+2d2+d3; out d=(-s) mod 11 in 0..10.
# core 0 streams the 4 running prefix sums (their total is s).
# core 4 sums -> s, coarse-reduces mod 33 (a multiple of 11), ships the remainder down.
# core 8 fine-reduces mod 11 and maps to d = 11-r (0 when r==0), emits. Loops pipeline.
@1
MOV ACC, UP
MOV DOWN, ACC
ADD UP
MOV DOWN, ACC
ADD UP
MOV DOWN, ACC
ADD UP
MOV DOWN, ACC
@4
MOV ACC, UP
ADD UP
ADD UP
ADD UP
JZ S
M: SUB 33
JG M
JZ S
ADD 33
S: MOV DOWN, ACC
@7
MOV ACC, UP
JZ D
N: SUB 11
JG N
JZ D
NEG
D: MOV DOWN, ACC