ocaml: phase 5.1 palindrome_sum.ml baseline (sum of 3-digit palindromes = 49500)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 24s

let palindrome_sum lo hi =
    let total = ref 0 in
    for n = lo to hi do
      if is_pal n then total := !total + n
    done;
    !total

  palindrome_sum 100 999 = 49500

There are 90 three-digit palindromes (form aba; 9 choices for a, 10
for b). Average value 550, sum 49500.

Companion to palindrome.ml (predicate-only) and paren_depth.ml.

127 baseline programs total.
This commit is contained in:
2026-05-10 01:29:52 +00:00
parent 0b79d4d4b4
commit fb0e83d3a1
3 changed files with 24 additions and 0 deletions

View File

@@ -407,6 +407,10 @@ _Newest first._
binary search tree (`type 'a tree = Leaf | Node of 'a * 'a tree *
'a tree`) with insert + in-order traversal. Tests parametric ADT,
recursive match, List.append, List.fold_left.
- 2026-05-10 Phase 5.1 — palindrome_sum.ml baseline (sum of 3-digit
palindromes = 49500). 90 palindromes between 100 and 999 (form
aba; 9 choices for a, 10 for b). Sum = 49500 = 90 * 550 (mean
is 550). 127 baseline programs total.
- 2026-05-10 Phase 5.1 — triangle_div.ml baseline (first triangle
number with > 10 divisors = 120). PE12 with target 10. T(15) = 120
has 16 divisors {1,2,3,4,5,6,8,10,12,15,20,24,30,40,60,120} —