fork(2) download
  1. f = lambda x,y:abs(x/-3-y/-3)+abs((x or 1.5)%-3-(y or 1.5)%-3)//1
  2.  
  3. for (x, y) in ((1, 4), (1, 8), (3, 7), (8, 2), (6, 1), (0, 9), (4, 4), (0, 4)):
  4. print '%d, %d: %d'%(x, y, f(x, y))
Success #stdin #stdout 0.02s 9016KB
stdin
Standard input is empty
stdout
1, 4: 1
1, 8: 3
3, 7: 4
8, 2: 2
6, 1: 3
0, 9: 4
4, 4: 0
0, 4: 2