Calculate the Numpad Taxicab
Jelly, 11 bytes
o-1.’d3ạ/ḞS
Try it online! or verify all test cases.
How it works
o-1.’d3ạ/ḞS Main link. Argument: [a, b] (list of integers)
-1. Yield -1.5.
o Take the logical OR of a and b with -1.5.
This maps 0 to -1.5, and all other integers to themselves.
’ Decrement the results.
d3 Divmod; compute quotient and remainder of each result divided by 3.
ạ/ Reduce by absolute difference across columns.
Ḟ Floor; round all differences down to the nearest integer.
S Sum; add the rounded absolute differences.
Python, 140 114 bytes
I am a first timer, so please help. Here's my code.
def f(x,y):x,y,k=x-1,y-1,abs;return x!=-1 and y!=-1 and k(y//3-x//3)+k(y%3-x%3) or k(y//3-x//3)+int(max(x,y)%3==2)
Jelly, 13 bytes
+2$.¹?€d3ạ/SḞ
Try it online!
Port of my Pyth answer.
Test suite.