ocaml: phase 5.1 min_cost_path.ml baseline (4x4 grid DP, optimal cost 12)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 22s

Standard 2D DP for min-cost path with right/down moves only:

  dp[i][j] = min(dp[i-1][j], dp[i][j-1]) + cost[i][j]

  cost:                  dp:
    1 3 1 2                1  4  5  7
    1 5 1 3                2  7  6  9
    4 2 1 4                6  8  7 11
    1 6 2 3                7 13  9 12

Optimal cost from (0,0) to (3,3) = 12.

Tests nested 2D arrays via Array.init + Array.make, double-nested
for-loops with branched edges (first row, first column, general),
mixed .(i-1).(j) read + .(i).(j)<- write on the same DP array.

161 baseline programs total.
This commit is contained in:
2026-05-10 22:37:44 +00:00
parent 5384ff6c42
commit c69a7694c8
3 changed files with 42 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 — min_cost_path.ml baseline (min-cost path
through 4×4 cost grid, top-left to bottom-right with moves
right/down only, optimal = 12). Standard 2D DP: dp[i][j] = min
of (dp[i-1][j], dp[i][j-1]) + cost[i][j]. Cost matrix yields
optimal path 1→1→2→1→1→1→2→3 = 12 (visiting (0,0),(1,0),(2,1),
(2,2),(2,3),(3,3)? actually the path is row-by-row). Tests
nested 2D arrays via Array.init + Array.make, double-nested
for-loops with branched edges (first row, first column, then
general case), `dp.(i-1).(j)` 2-D index read + `dp.(i).(j)<-`
2-D write. 161 baseline programs total.
- 2026-05-10 Phase 5.1 — topo_dfs.ml baseline (DFS-based topo sort
on the same 6-node DAG as topo_sort.ml, digit-fingerprint 24135).
Cons each node onto the order list AFTER recursing on all its