ocaml: phase 5.1 egg_drop.ml baseline (2 eggs, 36 floors -> 8 trials)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 23s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 23s
Classic egg-drop puzzle DP:
dp[e][f] = 1 + min over k in [1, f] of
max(dp[e-1][k-1], dp[e][f-k])
For 2 eggs over 36 floors, the optimal worst-case is 8 trials
(closed form: triangular number bound).
Tests 2D DP with triple-nested for-loops, max-of-two via inline
if, large sentinel constant (100000000), mixed shifted indexing
(e-1) and (f-k) where both shift independently.
163 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-10 Phase 5.1 — egg_drop.ml baseline (worst-case trials
|
||||
for 2 eggs, 36 floors = 8). Classic O(e·f²) DP: dp[e][f] = 1 +
|
||||
min over k of max(dp[e-1][k-1], dp[e][f-k]). Closed form via
|
||||
triangular numbers gives ⌈(√(1+8·36)−1)/2⌉ = 8, matching the
|
||||
DP answer. Tests 2D DP with triple-nested for-loops, max-of-two
|
||||
via inline if, large sentinel constant, mixed indexing (e-1)
|
||||
and (f-k) where both shift independently. 163 baseline programs
|
||||
total.
|
||||
- 2026-05-10 Phase 5.1 — polygon_area.ml baseline (shoelace formula
|
||||
on pentagon, returns 2× area = 32). Vertices (0,0), (4,0), (4,3),
|
||||
(2,5), (0,3); shoelace sum |Σ(x_i·y_{i+1} − x_{i+1}·y_i)| = 32 so
|
||||
|
||||
Reference in New Issue
Block a user