Syscall 2: Firmware, home

SignalChapter 9: Special nodes

68REPEATER

The task

P must receive each X value as many times as Y says. Y is from 1 to 3.

rep is an SC-2D: 10 lines, and every jump takes 3 cycles, JRX too.

The board

The board of REPEATER1 core: rep. Inputs X and Y; outputs P.repSC-2D 10 LINESP0P1P2XYP
The board as the puzzle screen lays it out. Cyan pins read, lemon pins write, violet pins go both ways. On a narrow screen, scroll the board sideways to see all of it.

Key idea

One JRX into a run of OUTs pays for one jump where a loop pays for one a copy.

Hints

Each hint goes a step further than the one before. Open them one at a time.

Hint 1Show

A loop pays for a jump on every copy. One JRX can pay once for the whole value.

Hint 2Show

Write three OUTs in a row and let JRX land on the right one.

Hint 3Show

JRX B jumps by B. Read Y first and work out the distance, then read X.

Solution

Reveal the Full SolutionThe complete program for REPEATER. Open it only when you want the answer.

The reference program

The game's own solution. It passes every test and scores exactly par on every benchmark.

repSC-2D signal processor

IN P1
NEG
ADD 4
MOV B, A
IN P0
JRX B
OUT P2
OUT P2
OUT P2
CYCLES
167
at par
ENERGY
634
at par
NODES
1
at par
INSTRUCTIONS
9
at par

Another way: Loop

A second program that also passes, by a different road, at a cost on CYCLES and ENERGY.

A loop that sends one copy a turn. It passes, but on an SC-2D every turn pays 3 cycles for each of its two jumps.

repSC-2D signal processor

S: IN P1
MOV B, A
IN P0
L: OUT P2
XCH A, B
SUB 1
JZ S
XCH A, B
JMP L
CYCLES
324
over par
ENERGY
1056
over par
NODES
1
at par
INSTRUCTIONS
9
at par