48ROUND TRIP
The task
X is a stream of frames: each frame is a few values and then a 0.
P must receive the sum of each frame and Q how many values it held.
A lone 0 is an empty frame, with a sum and a length of 0.
The board
Key idea
A frame needs a sum and a count, one more value than B holds, so a counter core sits on a loop.
Hints
Each hint goes a step further than the one before. Open them one at a time.
Hint 1Show
Keep the sum in B. There is no room for the count as well.
Hint 2Show
Send every value round to k, the 0 too, so k can see where a frame ends.
Hint 3Show
k counts in its own B and sends the count back when the 0 comes.
Solution
Reveal the Full SolutionThe complete program for ROUND TRIP. 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.
hSC-2 standard
S: IN P0
OUT P3
JZ E
ADD B
MOV B, A
JMP S
E: XCH A, B
OUT P1
IN P4
OUT P2kSC-2 standard
S: IN P0
JZ E
XCH A, B
ADD 1
MOV B, A
JMP S
E: XCH A, B
OUT P1- CYCLES
- 303
- at par
- ENERGY
- 2536
- at par
- NODES
- 2
- at par
- INSTRUCTIONS
- 18
- at par