WORM Solution
REMAINDER
WORM row 10

Prerequisites
Unlocks
w53 solved
Active cores0, 1, 2, 3, 6, 7
Program lines15
DetailWORM row 10
Walkthrough
REMAINDER: OUT = A mod B (true variable mod variable; B is 1..99).
A feeds core 0 (UP, stream 0); B feeds core 1 (UP, stream 1).
core 1 forwards B LEFT into core 0's RIGHT. core 0 loads A and takes one MOD
against the live divisor (a subtract loop would have to iterate A/B times for a
divisor it only learns at run time; MOD settles it in one cycle), then sends
the remainder DOWN the left column: core 0 -> core 3 -> core 6 (output 0).
Rack Solution
# REMAINDER: OUT = A mod B (true variable mod variable; B is 1..99).
# A feeds core 0 (UP, stream 0); B feeds core 1 (UP, stream 1).
# core 1 forwards B LEFT into core 0's RIGHT. core 0 loads A and takes one MOD
# against the live divisor (a subtract loop would have to iterate A/B times for a
# divisor it only learns at run time; MOD settles it in one cycle), then sends
# the remainder DOWN the left column: core 0 -> core 3 -> core 6 (output 0).
@0
MOV ACC, UP
MOD RIGHT
MOV DOWN, ACC
@1
MOV ACC, RIGHT
MOV LEFT, ACC
@3
MOV DOWN, UP
@6
MOV RIGHT, UP
@2
MOV LEFT, UP
@7
MOV DOWN, LEFT