Project Euler #91: Right triangles with integer coordinates

  • + 0 comments

    The key for this problem is to find out different kinds of triangle that can be formed in this setting. You won't want to iterate every pair of points to check whether a right triangle can be formed or not. Instead, you get a right triangle and check whether it is within the upper bound.

    Certain triangles are easy to get. Those with two side along x-axis and y-axis respectively. Those with one side along either axis where the axis itself is not hypotenuse. With some further observation you can get the rest based on the above triangles with rotation and gcd.