ocaml: phase 5.1 count_subarrays_k.ml baseline (sum-k subarrays = 7)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 24s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 24s
Count contiguous subarrays summing to a target k using a prefix
sum table:
prefix[i+1] = prefix[i] + arr[i]
count = |{ (i, j) : 0 <= i < j <= n, prefix[j] - prefix[i] = k }|
For arr = [1; 1; 1; 2; -1; 3; 1; -2; 4] and k = 3, the seven
witnesses are:
[1, 1, 1] (0..2)
[1, 1, 2, -1] (1..4)
[1, 2] (2..3)
[2, -1, 3, 1, -2] (3..7)
[-1, 3, 1] (4..6)
[3] (5..5)
[1, -2, 4] (6..8)
Negative-valued arrays exercise mixed-sign integer arithmetic.
186 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 — count_subarrays_k.ml baseline (count
|
||||
contiguous subarrays of [1;1;1;2;-1;3;1;-2;4] summing to k=3
|
||||
= 7). Prefix-sum brute force in O(n²): build cumulative array,
|
||||
enumerate (i,j) pairs and check prefix[j]−prefix[i]=k. The 7
|
||||
witnesses include [1,1,1], [1,1,2,−1], [1,2], [2,−1,3,1,−2],
|
||||
[−1,3,1], [3], [1,−2,4]. Negative-valued arrays exercise our
|
||||
evaluator's mixed-sign integer arithmetic (no underflow at the
|
||||
JS safe-int boundary). 186 baseline programs total.
|
||||
- 2026-05-11 Phase 5.1 — floyd_cycle.ml baseline (Floyd's tortoise
|
||||
-and-hare cycle detection on f(x) = (2x+5) mod 17; μ=0 λ=8 →
|
||||
encoded 8). Three phases: (1) advance slow/fast until they
|
||||
|
||||
Reference in New Issue
Block a user