Ad
  • Default User Avatar

    I made this a long time ago. But if I remember correctly, the distance from from cell 1 to cell 2 must always be computed not by abs(x2-x1) + abs(y2-y2) but instead more precisely with pythagorean's theorem sqrt((x2-x1)^2 + (y2-y1)^2)

    Using this formula, the distance of the three spaces in your example from the target or start would be 2, ≈1.41, and 2.

    So if i remember the kata correctly, the correct answer is the middle one of those three or (1,1) because it is the closest box within the circle of radius = 2 to the target box (2,2)

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Default User Avatar

    Yes, if the argument is a very large number.
    But the function correctly handles the case where n <= math.maxinteger, which should be enough.

  • Custom User Avatar

    Fixed.