project euler problem 9 https projecteuler netproblem9 special pythagorean triplet a pythagorean triplet is a set of three natural numbers a b c for which a2 b2 c2 for example 32 42 9 16 25 52 there exists exactly one pythagorean triplet for which a b c 1000 find the product abc references https en wikipedia orgwikipythagoreantriple returns the product of a b c which are pythagorean triplet that satisfies the following 1 a2 b2 c2 2 a b c 1000 solution 31875000 returns the product of a b c which are pythagorean triplet that satisfies the following 1 a 2 b 2 c 2 2 a b c 1000 solution 31875000
def solution() -> int:
    

    return next(
        iter(
            [
                a * b * (1000 - a - b)
                for a in range(1, 999)
                for b in range(a, 999)
                if (a * a + b * b == (1000 - a - b) ** 2)
            ]
        )
    )


if __name__ == "__main__":
    print(f"{solution() = }")