def find_pythagorean_triplet(n):
    """ Find a Pythagorean triplet a^2+b^2=c^2 for which a+b+c=`n`. """
    for c in range(n - 2, 0, -1):
        for a in range(n - c - 1, 0, -1):
            b = n - c - a
            # Check if a,b,c form a valid Pythagorean triplet.
            if a**2 + b**2 == c**2:
                return a, b, c