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
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 P1eySC-1 lite
IN P0
OUT P1
IN P0
OUT P2
IN P0
OUT P1w1SC-2 standard
IN P0
MOV B, A
MUL A
MUL B
OUT P2
IN P1
MOV B, A
MUL A
MUL B
OUT P2w2SC-2L low power
IN P0
MOV B, A
MUL A
MUL B
OUT P2
IN P1
MOV B, A
MUL A
MUL B
OUT P2jSC-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 P1eySC-1 lite
IN P0
OUT P1w1SC-2 standard
IN P0
MOV B, A
MUL A
MUL B
OUT P2
IN P1
MOV B, A
MUL A
MUL B
OUT P2jSC-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 P1eySC-1 lite
IN P0
OUT P2w1SC-2 standard
IN P0
MOV B, A
MUL A
MUL B
OUT P2w2SC-2L low power
IN P1
MOV B, A
MUL A
MUL B
OUT P2jSC-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