ocaml: phase 5.1 dp_word_break.ml baseline (4/5 strings segmentable)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 26s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 26s
Classic word-break DP — for each position i, check whether any
dictionary word ends at i with a prior reachable position:
dp[i] = exists w in dict with wl <= i and
dp[i - wl] && s.sub (i - wl) wl = w
Dictionary: apple, pen, pine, pineapple, cats, cat, and, sand, dog
Inputs:
applepenapple yes (apple pen apple)
pineapplepenapple yes (pineapple pen apple)
catsanddog yes (cats and dog)
catsandog no (no segmentation reaches the end)
applesand yes (apple sand)
Tests bool-typed Array, String.sub primitive, nested List.iter
over the dict inside for-loop over end positions, closure capture
of the outer dp.
179 baseline programs total.
This commit is contained in:
@@ -407,6 +407,14 @@ _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-11 Phase 5.1 — dp_word_break.ml baseline (word-break DP
|
||||
over 5 strings with 9-word dictionary; 4 strings segmentable).
|
||||
dp[i] = ∃ word w of length wl ≤ i with prefix s[i−wl..i]=w and
|
||||
dp[i−wl]=true. Inputs: applepenapple, pineapplepenapple,
|
||||
catsanddog (yes); catsandog (no — leftover "og"); applesand (yes).
|
||||
Tests bool-typed DP array, `String.sub s start len` substring
|
||||
primitive, nested List.iter over dict inside for-loop over
|
||||
positions, short-circuit + closure. 179 baseline programs total.
|
||||
- 2026-05-11 Phase 5.1 — histogram_area.ml baseline (largest
|
||||
rectangle in histogram [2;1;5;6;2;3] = 10). Linear-time stack
|
||||
algorithm: push indices while heights are non-decreasing; on
|
||||
|
||||
Reference in New Issue
Block a user