39PLATE STACK
The task
A value of X that is not 0 puts a plate on the stack. A 0 takes the top plate off to P.
A 0 on an empty stack sends 0. The stack never holds more than four plates.
The board
Key idea
A stack of four cores: a push shifts plates along, a pop asks the next core with a 0.
Hints
Each hint goes a step further than the one before. Open them one at a time.
Hint 1Show
Each core can hold one plate. Let 0 mean the core is empty.
Hint 2Show
A new plate pushes the old top one core along. Taking one off pulls the next one back.
Hint 3Show
Ask the next core for its plate by sending it a 0.
Solution
Reveal the Full SolutionThe complete program for PLATE STACK. 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.
hSC-2 standard
T: IN P0
OUT P1
JNZ T
IN P1
OUT P2s1SC-2 standard
T: MOV B, A
IN P0
JZ G
XCH A, B
JZ K
OUT P1
K: XCH A, B
JMP T
G: XCH A, B
OUT P0
JZ T
MOV A, 0
OUT P1
IN P1s2SC-2 standard
T: MOV B, A
IN P0
JZ G
XCH A, B
JZ K
OUT P1
K: XCH A, B
JMP T
G: XCH A, B
OUT P0
JZ T
MOV A, 0
OUT P1
IN P1s3SC-2 standard
T: MOV B, A
IN P0
JZ G
XCH A, B
JZ K
OUT P1
K: XCH A, B
JMP T
G: XCH A, B
OUT P0
JZ T
MOV A, 0
OUT P1
IN P1s4SC-2 standard
T: MOV B, A
IN P0
JNZ T
XCH A, B
OUT P0
XCH A, B- CYCLES
- 472
- at par
- ENERGY
- 6486
- at par
- NODES
- 5
- at par
- INSTRUCTIONS
- 53
- at par