40TAXICAB
The task
X and Y are one point and Z and W another. P must receive their distance on a grid.
That is the gap from X to Z plus the gap from Y to W, each counted as positive.
The board
Key idea
Two absolute gaps added where two branches meet.
Hints
Each hint goes a step further than the one before. Open them one at a time.
Hint 1Show
Each gap is a subtraction with its sign dropped.
Hint 2Show
JG can skip the NEG when the gap is already positive.
Hint 3Show
Add the two gaps where the branches meet.
Solution
Reveal the Full SolutionThe complete program for TAXICAB. 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.
g1SC-2 standard
IN P1
MOV B, A
IN P0
SUB B
JG K
NEG
K: OUT P2g2SC-2 standard
IN P1
MOV B, A
IN P0
SUB B
JG K
NEG
K: OUT P2tSC-2 standard
IN P0
MOV B, A
IN P1
ADD B
OUT P2- CYCLES
- 305
- at par
- ENERGY
- 4214
- at par
- NODES
- 3
- at par
- INSTRUCTIONS
- 19
- at par