84FAIR SHARE
The task
X holds frames of up to 6 numbers from 1 to 99, each ended by a 0.
P must receive each frame's sum over its count, and Q the remainder; an empty frame sends 0.
a is an SC-4, with C and D as well. k is an SC-2L: 2 cycles a line, half the energy.
The board
Key idea
The sum and the count of a frame meet in one core, which divides for the share and takes MOD for the rest; a divisor of 0 gives 0, so an empty frame needs no test.
Hints
Each hint goes a step further than the one before. Open them one at a time.
Hint 1Show
The sum and the count of a frame are both needed before d can divide.
Hint 2Show
MOV C, A keeps a copy of A in C, and MOV A, C brings it back.
Hint 3Show
A divide leaves A holding the answer, so d may need the sum sent twice.
Solution
Reveal the Full SolutionThe complete program for FAIR SHARE. 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.
aSC-4 quad
S: IN P0
JNZ K
XCH A, C
OUT P1
MOV A, 0
XCH A, B
OUT P1
OUT P1
JMP S
K: ADD B
MOV B, A
MOV A, C
ADD 1
MOV C, AdSC-2 standard
IN P0
MOV B, A
IN P0
DIV B
OUT P2
IN P0
MOD B
OUT P3- CYCLES
- 353
- at par
- ENERGY
- 3034
- at par
- NODES
- 2
- at par
- INSTRUCTIONS
- 22
- at par
Another way: Fair share count on k
A second program that also passes. It beats par on ENERGY and gives some back on CYCLES, NODES, and INSTRUCTIONS.
Less energy than par, but slower and on three nodes. a only sums, and the low power k counts the values a passes on.
aSC-4 quad
S: IN P0
OUT P2
JNZ K
XCH A, B
OUT P1
OUT P1
JMP S
K: ADD B
MOV B, AkSC-2L low power
S: IN P0
JNZ K
XCH A, B
OUT P1
JMP S
K: XCH A, B
ADD 1
XCH A, BdSC-2 standard
IN P1
MOV B, A
IN P0
DIV B
OUT P2
IN P0
MOD B
OUT P3- CYCLES
- 467
- over par
- ENERGY
- 2922
- under par
- NODES
- 3
- over par
- INSTRUCTIONS
- 25
- over par