Syscall 2: Firmware, home

SignalChapter 6: Trees

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

The board of TAXICAB3 cores: g1, g2, and t. Inputs W, X, Y, and Z; outputs P.g1SC-2 15 LINESg2SC-2 15 LINEStSC-2 6 LINESP0P1P2P0P1P2P0P1P2XZYWP
The board as the puzzle screen lays it out. Cyan pins read, lemon pins write, violet pins go both ways. On a narrow screen, scroll the board sideways to see all of it.

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 P2

g2SC-2 standard

IN P1
MOV B, A
IN P0
SUB B
JG K
NEG
K: OUT P2

tSC-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