This process assumes the solution triplet to be a multiple of one of a small set of known triplets. Starting with the first five.
from math import sqrt, trunc
def f_of_x(a, b, x):
return trunc(sqrt((a * x)**2 + (b * x)**2)), (a + b) * x
knowns = [(3,4), (5,12), (7,24), (8,15), (20,21)]
for k in knowns:
x = 0 # literally, x, the independent
r = (0,0)
while r[0] + r[1] < 1000:
x += 1
r = f_of_x(k[0], k[1], x) # return tuple includes h(x)
if r[0] + r[1] == 1000: # r[0] is f(x), r[1] is h(x)
a, b, c = k[0], k[1], r[0]
f = a * b * c * x**2 # solution
g = [(a * x, b * x, c), x, (k, c // x)] # report
break
print (f, g)
31875000 [(200, 375, 425), 25, ((8, 15), 17)]
The assumption is correct, in this instance. The solution is a multiple of the fourth in the set of knowns.This whole process is based on finite solutions without the use of brute force, while still trial and error. And it yields data. From a full on efficiency perspective it is probably wasteful owing to memory usage. A brute force approach will arrive at the same conclusion with less memory usage.
If my job depends upon it, brute force it is. If exploration is at hand, then break it down. Step by step, and let the code explain it to the reader.