4 added explanation
source | link

Japt, 3 2 bytes

gy

Somehow, somehow, I found an extremely hacky 2-byte solution...


North outputs 0:

gy

Since there's no implicit input, it defaults to 0. g on a number returns the sign of the number regardless of its arguments ("y" in this case).


East outputs 2:

g
y

In a multi-line program, the first line sets the input to its result. This is basically a no-op, since g on 0 is 0. Then y returns the GCD of 0 and... since it's missing an argument, it defaults to 2 (thanks, @Oliver!). This gives 2 as the output.

 

South outputs g:

yg

y, as before, is GCD. Since gcd(0, x) is x for any value, y on 0 takes the liberty of just returning its argument. In this case, the argument is "g", which is the result.


West outputs 1:

y
g

y on 0, as before, returns 2. This is then passed to g, which (as already discussed) is the sign function on numbers. Therefore, the result is 1.

Japt, 3 2 bytes

gy

Somehow, somehow, I found an extremely hacky 2-byte solution...


North outputs 0:

gy

East outputs 2:

g
y

South outputs g:

yg

West outputs 1:

y
g

Japt, 3 2 bytes

gy

Somehow, somehow, I found an extremely hacky 2-byte solution...


North outputs 0:

gy

Since there's no implicit input, it defaults to 0. g on a number returns the sign of the number regardless of its arguments ("y" in this case).


East outputs 2:

g
y

In a multi-line program, the first line sets the input to its result. This is basically a no-op, since g on 0 is 0. Then y returns the GCD of 0 and... since it's missing an argument, it defaults to 2 (thanks, @Oliver!). This gives 2 as the output.

 

South outputs g:

yg

y, as before, is GCD. Since gcd(0, x) is x for any value, y on 0 takes the liberty of just returning its argument. In this case, the argument is "g", which is the result.


West outputs 1:

y
g

y on 0, as before, returns 2. This is then passed to g, which (as already discussed) is the sign function on numbers. Therefore, the result is 1.

3 golfed another byte
source | link

Japt, 33 2 bytes

2Qggy

Somehow, somehow, I found an extremely hacky 2-byte solution...


NorthNorth outputs "0:

2Qggy

EastEast outputs 12:

2
Q
g
y

SouthSouth outputs 0g:

gQ2yg

WestWest outputs 21:

g
Qy
2g

Japt, 3 bytes

2Qg

North outputs ":

2Qg

East outputs 1:

2
Q
g

South outputs 0:

gQ2

West outputs 2:

g
Q
2

Japt, 3 2 bytes

gy

Somehow, somehow, I found an extremely hacky 2-byte solution...


North outputs 0:

gy

East outputs 2:

g
y

South outputs g:

yg

West outputs 1:

y
g
2 golfed 2 bytes
source | link

Japt, 53 bytes

Q1
ST2Qg

Test it online!


NorthNorth outputs 0":

Q1
ST2Qg

EastEast outputs 1:

SQ2
T1Q
g

SouthSouth outputs "0:

TS
1QgQ2

WestWest outputs 2:

1Tg
QSQ
2

Japt, 5 bytes

Q1
ST

Test it online!


North outputs 0:

Q1
ST

East outputs 1:

SQ
T1

South outputs ":

TS
1Q

West outputs :

1T
QS

Japt, 3 bytes

2Qg

North outputs ":

2Qg

East outputs 1:

2
Q
g

South outputs 0:

gQ2

West outputs 2:

g
Q
2
1
source | link