Skip to main content
improved explanation
Source Link
Neil
  • 185.1k
  • 12
  • 77
  • 292

Charcoal, 75 bytes

≔⊕NθFθFιF⌕AX…¹θ²ΣX⊕⟦κι⟧²⊞υ⊕⟦κιλ⟧FυFυ¿∧⁼⌈ι⌈κ���ικF…ι²Eօ겋⁺λμθ⭆¹⟦↔⁻λμ⁺λμ⌈ι

Try it online! Link is to verbose version of code. Explanation: Possibly not the shortest approach, but it only uses integer arithmetic. Points B and C on the circle must have integer coordinates, along with both distances MB and MC being the integer r, therefore taking two different Pythagorean triples with the same hypotenuse will generate four solutions (although some of them may result in m > X which must then be excluded).

≔⊕Nθ

Increment X as this saves bytes on the ranges and conditions.

FθFιF⌕AX…¹θ²ΣX⊕⟦κι⟧²⊞υ⊕⟦κιλ⟧

Loop over all p and q values to find Pythagorean triples p, q, r with p < q < r <= X.

FυFυ¿∧⁼⌈ι⌈κ‹ικ

Loop over (distinct) pairs of Pythagorean triples p, q, r and p', q', r where p < p' < q' < q < r.

F…ι²Eօ겋⁺λμθ⭆¹⟦↔⁻λμ⁺λμ⌈ι

Loop s over p and q and s' over p' and q' where s + s' <= X and output the triple m = |s - s|', n = s + s', r.

Charcoal, 75 bytes

≔⊕NθFθFιF⌕AX…¹θ²ΣX⊕⟦κι⟧²⊞υ⊕⟦κιλ⟧FυFυ¿∧⁼⌈ι⌈κ‹ικF…ι²Eօ겋⁺λμθ⭆¹⟦↔⁻λμ⁺λμ⌈ι

Try it online! Link is to verbose version of code. Explanation: Possibly not the shortest approach, but it only uses integer arithmetic.

≔⊕Nθ

Increment X as this saves bytes on the ranges and conditions.

FθFιF⌕AX…¹θ²ΣX⊕⟦κι⟧²⊞υ⊕⟦κιλ⟧

Loop over all p and q values to find Pythagorean triples p, q, r with p < q < r <= X.

FυFυ¿∧⁼⌈ι⌈κ‹ικ

Loop over (distinct) pairs of Pythagorean triples p, q, r and p', q', r where p < p' < q' < q < r.

F…ι²Eօ겋⁺λμθ⭆¹⟦↔⁻λμ⁺λμ⌈ι

Loop s over p and q and s' over p' and q' where s + s' <= X and output the triple m = |s - s|', n = s + s', r.

Charcoal, 75 bytes

≔⊕NθFθFιF⌕AX…¹θ²ΣX⊕⟦κι⟧²⊞υ⊕⟦κιλ⟧FυFυ¿∧⁼⌈ι⌈κ‹ικF…ι²Eօ겋⁺λμθ⭆¹⟦↔⁻λμ⁺λμ⌈ι

Try it online! Link is to verbose version of code. Explanation: Possibly not the shortest approach, but it only uses integer arithmetic. Points B and C on the circle must have integer coordinates, along with both distances MB and MC being the integer r, therefore taking two different Pythagorean triples with the same hypotenuse will generate four solutions (although some of them may result in m > X which must then be excluded).

≔⊕Nθ

Increment X as this saves bytes on the ranges and conditions.

FθFιF⌕AX…¹θ²ΣX⊕⟦κι⟧²⊞υ⊕⟦κιλ⟧

Loop over all p and q values to find Pythagorean triples p, q, r with p < q < r <= X.

FυFυ¿∧⁼⌈ι⌈κ‹ικ

Loop over (distinct) pairs of Pythagorean triples p, q, r and p', q', r where p < p' < q' < q < r.

F…ι²Eօ겋⁺λμθ⭆¹⟦↔⁻λμ⁺λμ⌈ι

Loop s over p and q and s' over p' and q' where s + s' <= X and output the triple m = |s - s|', n = s + s', r.

added 22 characters in body
Source Link
Neil
  • 185.1k
  • 12
  • 77
  • 292

Charcoal, 7575 bytes

≔⊕NθFθFιF⌕AX…¹θ²ΣX⊕⟦κι⟧²⊞υ⊕⟦κιλ⟧FυFυ¿›⁼⌈ι⌈κ⁼ικF…ι²EΦ…κ²∧›λμ‹⁺λμθ⭆¹⟦⁻λμ⁺λμ⌈ι≔⊕NθFθFιF⌕AX…¹θ²ΣX⊕⟦κι⟧²⊞υ⊕⟦κιλ⟧FυFυ¿∧⁼⌈ι⌈κ‹ικF…ι²Eօ겋⁺λμθ⭆¹⟦↔⁻λμ⁺λμ⌈ι

Try it online!Try it online! Link is to verbose version of code. Explanation: Possibly not the shortest approach, but it only uses integer arithmetic.

≔⊕Nθ

Increment X as this saves bytes on the ranges and conditions.

FθFιF⌕AX…¹θ²ΣX⊕⟦κι⟧²⊞υ⊕⟦κιλ⟧

Loop over all p and q values to find Pythagorean triples p, q, r with p < q < r <= X.

FυFυ¿›⁼⌈ι⌈κ⁼ικFυFυ¿∧⁼⌈ι⌈κ‹ικ

Loop over distinct(distinct) pairs of Pythagorean triples p, q, r and p', q', r where p < p' < q' < q < r.

F…ι²EΦ…κ²∧›λμ‹⁺λμθ⭆¹⟦⁻λμ⁺λμ⌈ιF…ι²Eօ겋⁺λμθ⭆¹⟦↔⁻λμ⁺λμ⌈ι

Loop s over p and q and s' over p' and q' where s > s' and s + s' <= X and output the triple m = s|s - s's|', n = s + s', r.

Charcoal, 75 bytes

≔⊕NθFθFιF⌕AX…¹θ²ΣX⊕⟦κι⟧²⊞υ⊕⟦κιλ⟧FυFυ¿›⁼⌈ι⌈κ⁼ικF…ι²EΦ…κ²∧›λμ‹⁺λμθ⭆¹⟦⁻λμ⁺λμ⌈ι

Try it online! Link is to verbose version of code. Explanation: Possibly not the shortest approach, but it only uses integer arithmetic.

≔⊕Nθ

Increment X as this saves bytes on the ranges and conditions.

FθFιF⌕AX…¹θ²ΣX⊕⟦κι⟧²⊞υ⊕⟦κιλ⟧

Loop over all p and q values to find Pythagorean triples p, q, r with p < q < r <= X.

FυFυ¿›⁼⌈ι⌈κ⁼ικ

Loop over distinct pairs of Pythagorean triples p, q, r and p', q', r.

F…ι²EΦ…κ²∧›λμ‹⁺λμθ⭆¹⟦⁻λμ⁺λμ⌈ι

Loop s over p and q and s' over p' and q' where s > s' and s + s' <= X and output the triple m = s - s', n = s + s', r.

Charcoal, 75 bytes

≔⊕NθFθFιF⌕AX…¹θ²ΣX⊕⟦κι⟧²⊞υ⊕⟦κιλ⟧FυFυ¿∧⁼⌈ι⌈κ‹ικF…ι²Eօ겋⁺λμθ⭆¹⟦↔⁻λμ⁺λμ⌈ι

Try it online! Link is to verbose version of code. Explanation: Possibly not the shortest approach, but it only uses integer arithmetic.

≔⊕Nθ

Increment X as this saves bytes on the ranges and conditions.

FθFιF⌕AX…¹θ²ΣX⊕⟦κι⟧²⊞υ⊕⟦κιλ⟧

Loop over all p and q values to find Pythagorean triples p, q, r with p < q < r <= X.

FυFυ¿∧⁼⌈ι⌈κ‹ικ

Loop over (distinct) pairs of Pythagorean triples p, q, r and p', q', r where p < p' < q' < q < r.

F…ι²Eօ겋⁺λμθ⭆¹⟦↔⁻λμ⁺λμ⌈ι

Loop s over p and q and s' over p' and q' where s + s' <= X and output the triple m = |s - s|', n = s + s', r.

Source Link
Neil
  • 185.1k
  • 12
  • 77
  • 292

Charcoal, 75 bytes

≔⊕NθFθFιF⌕AX…¹θ²ΣX⊕⟦κι⟧²⊞υ⊕⟦κιλ⟧FυFυ¿›⁼⌈ι⌈κ⁼ικF…ι²EΦ…κ²∧›λμ‹⁺λμθ⭆¹⟦⁻λμ⁺λμ⌈ι

Try it online! Link is to verbose version of code. Explanation: Possibly not the shortest approach, but it only uses integer arithmetic.

≔⊕Nθ

Increment X as this saves bytes on the ranges and conditions.

FθFιF⌕AX…¹θ²ΣX⊕⟦κι⟧²⊞υ⊕⟦κιλ⟧

Loop over all p and q values to find Pythagorean triples p, q, r with p < q < r <= X.

FυFυ¿›⁼⌈ι⌈κ⁼ικ

Loop over distinct pairs of Pythagorean triples p, q, r and p', q', r.

F…ι²EΦ…κ²∧›λμ‹⁺λμθ⭆¹⟦⁻λμ⁺λμ⌈ι

Loop s over p and q and s' over p' and q' where s > s' and s + s' <= X and output the triple m = s - s', n = s + s', r.