Project Euler 309 - Integer Ladders
Official link: https://projecteuler.net/problem=309
Thought Process
A bit of research lands you on Crossed Ladders Problem, which is enough to solve the problem!
The page illustrated has a very useful property, 1/A + 1/B = 1/h, which I will prove.
Knowing this we can just generate pythagorean triples with the hypotenuse no longer than 1,000,000 and match triangles with a matching side and test if the other sides, A and B, have the property that AB is divisible by A + B. I used my pythagorean triple generator.
In order to be efficient, I created an array such that array[x] contains all pythagorean triplets with a side x and incorporated this into my Pythagorean triple generator such that it returns me this completed array.
Now I can just loop through my array and test only the triangles with at-least one matching side. Remember to make sure that x < y!
Interactive Code
Input an integer (yourinput)
Code outputs the number of triplets (x, y, h) produce integer solutions for w such that 0 < x < y < yourinput