95TAKE TURNS
The task
a, b, c, and d share a bus. X arrives at a, Y at b, and Z at c.
P, on d, must receive X plus Y plus Z.
The board
Key idea
Three writers and one reader: the writers on the left must wait their turn, or the rounds mix.
Hints
Each hint goes a step further than the one before. Open them one at a time.
Hint 1Show
When several cores have written, d takes a's value first, then b's, then c's.
Hint 2Show
But a can write its next X before d has read Z, and then a's goes first again.
Hint 3Show
Let a and b wait their turn after each value, until c's has gone.
Solution
Reveal the Full SolutionThe complete program for TAKE TURNS. 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.
aSC-2 standard
IN P0
OUT P1
NOP
NOP
NOPbSC-2 standard
IN P1
OUT P0
NOPcSC-2 standard
IN P0
OUT P1dSC-2 standard
IN P0
MOV B, A
IN P0
ADD B
MOV B, A
IN P0
ADD B
OUT P1- CYCLES
- 354
- at par
- ENERGY
- 4212
- at par
- NODES
- 4
- at par
- INSTRUCTIONS
- 18
- at par