12TALLY
The task
P must receive the running total of X. A zero clears the total and sends 0.
IN overwrites A, so the total has to live somewhere else.
The board
Key idea
A counter that resets on zero; a value needed twice is sent twice.
Hints
Each hint goes a step further than the one before. Open them one at a time.
Hint 1Show
B keeps a value while A reads the next one.
Hint 2Show
ADD B then MOV B, A adds the value to the total and keeps the new total.
Hint 3Show
JZ jumps when A is 0, JNZ when it is not. A zero in A is also the new total.
Solution
Reveal the Full SolutionThe complete program for TALLY. 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
JZ N
ADD B
N: MOV B, A
OUT P1- CYCLES
- 230
- at par
- ENERGY
- 1590
- at par
- NODES
- 2
- at par
- INSTRUCTIONS
- 7
- at par