56CHECKSUM GATE
The task
X is a stream of frames, each ended by a 0. The first value is a check and the rest are data.
If the data add up to the check, P must receive the data and the 0. If not, the frame is lost.
Each frame holds 1 to 3 data values.
The board
Key idea
Check first, store the data in a line, then tell the gate to pass or drop it.
Hints
Each hint goes a step further than the one before. Open them one at a time.
Hint 1Show
The answer is known only when the frame ends, so the data must wait in the line.
Hint 2Show
Take each data value away from the check as it passes. 0 left means the frame is good.
Hint 3Show
Tell g whether to pass or drop the frame before it starts reading the line.
Solution
Reveal the Full SolutionThe complete program for CHECKSUM GATE. 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.
mSC-2 standard
IN P0
NEG
MOV B, A
L: IN P0
OUT P1
JZ E
ADD B
MOV B, A
JMP L
E: ADD B
OUT P2q1SC-2 standard
IN P0
OUT P1q2SC-2 standard
IN P0
OUT P1q3SC-2 standard
IN P0
OUT P1q4SC-2 standard
IN P0
OUT P1gSC-2 standard
S: IN P1
JZ K
DN: IN P0
JNZ DN
JMP S
K: IN P0
OUT P2
JNZ K- CYCLES
- 243
- at par
- ENERGY
- 2754
- at par
- NODES
- 6
- at par
- INSTRUCTIONS
- 27
- at par