Lunnon had the right idea but got some details wrong. I repair here. Lunnon's first point is we only need to consider the distance from (0,0) to (x,y) for SORTED (decreasing) (x,y), i.e. with x>=y>=0. Lunnon's nicer rewriting of WDS's Knight-distance algorithm, call the returned value f(x,y): X = max(|x|,|y|); Y = min(|x|,|y|); p = X-Y; q = p-Y; if(q<0) r=3 else r=4 if(X=1 and Y=0) return distance = 3 if(X=2 and Y=2) return distance = 4 return distance = p - 2*floor(q/r); Proof of validity: By induction. Base case is verifying it when 0<=x,y<=8. [Both Lunnon and I did that.] Induction is that, if we are outside the base case, and x>=y>=0, then f(x,y)=f(x-2,y-1)+1. To establish this there are 3 cases: i. (x',y') = (x-2, y-1) also obeys the assumptions x>=y>=0 and min(x,y)>8, or ii. x=y, in which case p=0,q=-x,r=3,f=-2*floor(-x/3); let (x',y')=(x-1,x-2). iii. y=0, in which case p=x,q=x,r=4,f=x-2*floor(x/4); let (x',y')=(x-2,1). In case i, we have p'=p-1 and q'=q and r'=r hence f'=f-1. In case ii, p'=1, q'=3-x, r'=3, hence f'=1-2*floor((3-x)/3)=-1-2*floor(-x/3)=f-1. Lunnon had a wrong proof for this case, but the conclusion f'=f-1 is what matters, and that works. In case iii, which Lunnon just failed to consider, we have p'=x-3, q'=x-4, r'=4, f'=x-3-2*floor((x-4)/4)=x-1-2*floor(x/4)=f-1. No matter which case, you conclude f'=f-1, which is the inductive claim we needed. Q.E.D. -- Warren D. Smith http://RangeVoting.org