18STREAK
The task
For each value, P must receive how many equal values in a row end with it.
The stream runs out along the top and back along the bottom to P.
The board
Key idea
Run length, with state that resets on a change.
Hints
Each hint goes a step further than the one before. Open them one at a time.
Hint 1Show
The second core can compare each value with the one before it.
Hint 2Show
Send the difference on. A zero means the streak goes on.
Hint 3Show
The last core keeps the count in B.
Solution
Reveal the Full SolutionThe complete program for STREAK. 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.
c0SC-2 standard
IN P0
OUT P1c1SC-2 standard
IN P0
SUB B
OUT P1
ADD B
MOV B, Ac2SC-2 standard
T: IN P0
JZ S
MOV A, 1
MOV B, A
JMP O
S: XCH A, B
ADD 1
MOV B, A
O: OUT P1- CYCLES
- 279
- at par
- ENERGY
- 3042
- at par
- NODES
- 3
- at par
- INSTRUCTIONS
- 16
- at par