Syscall 2: Firmware, home

SignalChapter 10: Meshes

79INTERCHANGE

The task

P must receive each X cubed, and Q must receive each Y cubed.

w1 and j are standard cores, and w2 an SC-2L: 2 cycles an instruction, at half the energy.

ex and ey are SC-1s: register A only, 8 lines.

The board

The board of INTERCHANGE5 cores: ex, ey, w1, w2, and j. Inputs X and Y; outputs P and Q.exSC-1 8 LINESeySC-1 8 LINESw1SC-2 15 LINESw2SC-2L 15 LINESjSC-2 15 LINESP0P1P2P0P1P2P0P1P2P0P1P2P0P1P2P3XYPQ
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

Two streams share two workers of different speeds, two jobs to the fast one for each one to the slow one; the collector reads each answer as soon as it can.

Hints

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

Hint 1Show

Both workers can serve both streams, so neither stream waits on the slow worker alone.

Hint 2Show

The fast worker can take two jobs for each one the slow worker takes.

Hint 3Show

j can mix P and Q answers in any order that keeps each stream in turn; a worker waits on j.

Solution

Reveal the Full SolutionThe complete program for INTERCHANGE. 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.

exSC-1 lite

IN P0
OUT P1
IN P0
OUT P2
IN P0
OUT P1

eySC-1 lite

IN P0
OUT P1
IN P0
OUT P2
IN P0
OUT P1

w1SC-2 standard

IN P0
MOV B, A
MUL A
MUL B
OUT P2
IN P1
MOV B, A
MUL A
MUL B
OUT P2

w2SC-2L low power

IN P0
MOV B, A
MUL A
MUL B
OUT P2
IN P1
MOV B, A
MUL A
MUL B
OUT P2

jSC-2 standard

IN P0
OUT P2
IN P1
OUT P2
IN P0
OUT P3
IN P0
OUT P2
IN P1
OUT P3
IN P0
OUT P3
CYCLES
369
at par
ENERGY
3354
at par
NODES
5
at par
INSTRUCTIONS
44
at par

Another way: Fast only

A second program that also passes. It beats par on NODES and INSTRUCTIONS and gives some back on CYCLES and ENERGY.

W1 cubes everything and w2 sits idle: one core fewer and far fewer lines, but slower, and w1 spends 2 energy on every instruction.

exSC-1 lite

IN P0
OUT P1

eySC-1 lite

IN P0
OUT P1

w1SC-2 standard

IN P0
MOV B, A
MUL A
MUL B
OUT P2
IN P1
MOV B, A
MUL A
MUL B
OUT P2

jSC-2 standard

IN P0
OUT P2
IN P0
OUT P3
CYCLES
473
over par
ENERGY
3744
over par
NODES
4
under par
INSTRUCTIONS
18
under par

Another way: Own worker

A second program that also passes. It beats par on ENERGY and INSTRUCTIONS and gives some back on CYCLES.

W1 cubes every X and w2 every Y: less energy and far fewer lines, but Q waits on the slow worker alone.

exSC-1 lite

IN P0
OUT P1

eySC-1 lite

IN P0
OUT P2

w1SC-2 standard

IN P0
MOV B, A
MUL A
MUL B
OUT P2

w2SC-2L low power

IN P1
MOV B, A
MUL A
MUL B
OUT P2

jSC-2 standard

IN P0
OUT P2
IN P1
OUT P3
CYCLES
433
over par
ENERGY
3159
under par
NODES
5
at par
INSTRUCTIONS
18
under par