Syscall 2: Firmware, home

SignalChapter 3: Chains and rings

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

The board of STREAK3 cores: c0, c1, and c2. Inputs X; outputs P.c0SC-2 15 LINESc1SC-2 15 LINESc2SC-2 15 LINESP0P1P0P1P0P1XP
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

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 P1

c1SC-2 standard

IN P0
SUB B
OUT P1
ADD B
MOV B, A

c2SC-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