ocaml: phase 5.1 manacher.ml baseline (longest palindrome "babadaba" = 7)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 25s

Manacher's algorithm: insert # separators (length 2n+1) to unify
odd/even cases, then maintain palindrome radii p[] alongside a
running (center, right) pair to skip work via mirror reflection.
Linear time.

  manacher "babadaba" = 7   (* witness: "abadaba", positions 1..7 *)

Note: requires parenthesizing the if-expression on the rhs of <-:

  p.(i) <- (if pm < v then pm else v)

Real OCaml parses bare `if` at <-rhs since the rhs is at expr
level; our parser places <-rhs at binop level which doesn't include
`if` / `match` / `let`. Workaround until we relax the binop
RHS grammar.

149 baseline programs total.
This commit is contained in:
2026-05-10 05:58:05 +00:00
parent 526ffbb5f0
commit cccef832d9
3 changed files with 43 additions and 0 deletions

View File

@@ -407,6 +407,16 @@ _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 — manacher.ml baseline (Manacher's longest
palindromic substring on "babadaba" = 7). Inserts `#` separators
to unify odd/even cases (string of length 2n+1), then maintains
palindrome radii in `p[]` plus a current rightmost-reach pair
(center, right). Linear time. The full input "babadaba" itself is
not a palindrome, but "abadaba" (positions 1..7) is — length 7.
Note: `p.(i) <- if pm < v then pm else v` requires explicit
parens — our parser doesn't accept `if` as the rhs of `<-` at
binop level (real OCaml does); workaround until we relax binop
RHS parsing. 149 baseline programs total.
- 2026-05-10 Phase 5.1 — floyd_warshall.ml baseline (all-pairs
shortest path on 4-node weighted graph, dist 0→3 = 9). Standard
O(n³) DP: for each intermediate vertex k, relax all (i,j) pairs.