ocaml: phase 5.1 flood_fill.ml baseline (largest grid component = 7)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 21s

Recursive 4-way flood fill from every unvisited 1-cell:

  let rec flood visited r c =
    if r < 0 || r >= h || c < 0 || c >= w then 0
    else if visited.(r).(c) || grid.(r).(c) = 0 then 0
    else begin
      visited.(r).(c) <- true;
      1 + flood visited (r - 1) c
        + flood visited (r + 1) c
        + flood visited r (c - 1)
        + flood visited r (c + 1)
    end

Grid (1s shown as #, 0s as .):
  # # . # #
  # . . . #
  . . # . .
  # # # # .
  . . . # #

Largest component: {(2,2),(3,0),(3,1),(3,2),(3,3),(4,3),(4,4)} = 7.

Bounds check r >= 0 must short-circuit before visited/grid reads;
relies on the && / || fix from iter 242.

157 baseline programs total.
This commit is contained in:
2026-05-10 21:57:42 +00:00
parent e057d9f18f
commit 3ea8967571
3 changed files with 47 additions and 0 deletions

View File

@@ -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 — flood_fill.ml baseline (largest connected
component in 5×5 grid = 7). Recursive 4-direction flood from
every unvisited 1-cell; bounds check short-circuits before the
visited/grid reads (relies on iter-242 fix). The maximal
component in the test grid spans {(2,2), (3,0), (3,1), (3,2),
(3,3), (4,3), (4,4)} = 7 cells. Tests recursive function with
4-way self-call, in-place visited array mutation, nested
short-circuited bounds + content guards. 157 baseline programs total.
- 2026-05-10 Phase 5.1 — next_permutation.ml baseline (count
permutations of [1;2;3;4;5] via Narayana's algorithm = 119).
Standard in-place algorithm: find largest i with a.(i) < a.(i+1),