57POWERS
The task
P must receive X to the power Y: X multiplied by itself Y times.
X is from 2 to 9, Y is from 0, and the answer always fits in a signed byte.
Multiply in a loop; a power of 0 is 1.
The board
Key idea
A loop inside a loop: TIMES TABLE run Y times, its result fed back in as the next X.
Hints
Each hint goes a step further than the one before. Open them one at a time.
Hint 1Show
This is TIMES TABLE inside a loop: multiply the answer by X once for each step of Y.
Hint 2Show
k only needs X once. Keep it in B and count down each answer it is sent.
Hint 3Show
Send k a 0 when the power is done, so it knows the next value is a new X.
Solution
Reveal the Full SolutionThe complete program for POWERS. 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.
pwSC-2 standard
IN P0
OUT P3
IN P1
MOV B, A
MOV A, 1
L: XCH A, B
JZ DN
SUB 1
XCH A, B
OUT P3
IN P4
JMP L
DN: OUT P3
XCH A, B
OUT P2kSC-2 standard
S: IN P0
MOV B, A
L: IN P0
JZ S
M: XCH A, B
OUT P1
XCH A, B
SUB 1
JNZ M
OUT P1
JMP LsSC-2 standard
S: IN P0
JZ E
ADD B
MOV B, A
JMP S
E: XCH A, B
OUT P1- CYCLES
- 2129
- at par
- ENERGY
- 15318
- at par
- NODES
- 3
- at par
- INSTRUCTIONS
- 33
- at par