limit. A triple (a, b, c) works if a² + b² = c²: a and b are the legs and c is the hypotenuse.
Return how many such triples have all three numbers between 1 and limit. The order of the legs matters: (3, 4, 5) and (4, 3, 5) are two different triples.limit=5 → 2
Only the 3-4-5 triangle fits, and its legs can be listed in two orders: (3, 4, 5) and (4, 3, 5).
limit=13 → 6
The triangles 3-4-5, 6-8-10 and 5-12-13, each with two orders of the legs, give 6.
limit=4 → 0
The smallest triangle needs a hypotenuse of 5, which exceeds limit.
limit ≤ 1000limit=5
2
Run checks the first 3 tests in your browser. Submit checks all 26 tests on the server, hidden ones included.