Files
rose-ash/plans
giles 288c0f8c3e
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 23s
ocaml: phase 5.1 euler9.ml baseline (Project Euler #9, abc = 31875000)
Find the unique Pythagorean triple with a + b + c = 1000 and
return their product.

The naive triple loop timed out under host contention (10-minute
cap exceeded with ~333 * 999 ~= 333k inner iterations of complex
checks). Rewritten with algebraic reduction:

  a + b + c = 1000  AND  a^2 + b^2 = c^2
  =>  b = (500000 - 1000 * a) / (1000 - a)

so only the outer a-loop is needed (333 iterations). Single-pass
form:

  for a = 1 to 333 do
    let num = 500000 - 1000 * a in
    let den = 1000 - a in
    if num mod den = 0 then begin
      let b = num / den in
      if b > a then
        let c = 1000 - a - b in
        if c > b then result := a * b * c
    end
  done

Triple (200, 375, 425), product 31875000.

103 baseline programs total.
2026-05-09 20:36:43 +00:00
..