Right Triangles with Integer Coordinates (91)
In Problem 91, we're asked to find right triangles on a grid of integer coordinates.
Brute force
The coordinates in the grid extend from 0 to 51 for both
The check whether something is a right triangle is rather easy: Compute the three side lengths squared:
Then find the longest side length and call it
One has to be a bit careful not to count triangles twice when
My Rust implementation runs in 39 ms, so clearly fast enough. Perhaps there is a more clever way to this, but one doesn't need to.