You are viewing a single comment's thread. Return to all comments →
Was stuck with the mindset to calculate the primitive triplets of a given perimeter (loop based on the perimeter) one after another, and it was too slow.
Then I swiched to looping on odd and even m and its corresponding n, and even with occasional gcd() does not make it unacceptably slow. The rest is just implementation of precalculation and dynamic programming. Takes more than 2s in Python, though.