Skip to main content
6 of 8
added a note
Arnauld
  • 206.5k
  • 21
  • 189
  • 673

JavaScript (V8), 121 bytes

A naive solution that prints the triplets m n r.

X=>{for(m=++X;m--;)for(n=X;--n>m;)for(x=X;x--;d=(m*m+n*n+x*x+y*y)**.5,d%2||y<x|d>X*2|m+n>=d|m==x||print(m,n,d/2))y=m*n/x}

Try it online!

A note about Math.hypot()

The diameter \$d\$ really should be computed with d=Math.hypot(m,n,x,y) (saving 2 bytes). Unfortunately, this leads to rounding errors on some cases and invalidates some valid solutions.

Arnauld
  • 206.5k
  • 21
  • 189
  • 673