Problem 38

Integer right triangles

Problem 40

Integer right triangles

Problem 39

If p is the perimeter of a right angle triangle with integral length sides, {a,b,c}, there are exactly three solutions for p = 120.
{20,48,52}, {24,45,51}, {30,40,50}
For which value of p ≤ 1000, is the number of solutions maximised?
def run(limit=1000):
    # num solutions, perimeter
    smax = 0, 0
    for p in range(1, limit):
        t = 0
        for a in range(2, p / 4 + 1):
            if (p * p - 2 * p * a) % (2 * p - 2 * a) == 0:
                t += 1
        if t > smax[0]:
            smax = t, p
    return smax[1]