Oh ya... true >_< Thanks :D
On Monday, May 25, 2015 at 9:43:47 PM UTC-7, Ian wrote: > > def distance(A, B): > > """ > > A & B are objects with x and y attributes > > :return: the distance between A and B > > """ > > dx = B.x - A.x > > dy = B.y - A.y > > a = min(dx, dy) > > b = max(dx, dy) > > if a == 0: > > return b > > elif b == 0: > > return a > > This branch is incorrect because a could be negative. > > You don't need this anyway; the a == 0 branch is only there because of > the division by a in the else branch. > > > else: > > return a * sqrt(1 + (b / a)**2) > > Same issue; if a is negative then the result will have the wrong sign. -- https://mail.python.org/mailman/listinfo/python-list