ocaml: phase 5.1 floyd_cycle.ml baseline (tortoise-hare, mu=0 lam=8 -> 8)
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
Floyd's cycle detection on a numeric function f(x) = (2x + 5) mod 17.
Three phases:
Phase 1: advance slow/fast until collision inside the cycle
(fast double-steps, slow single-steps)
Phase 2: restart slow from x0; advance both by 1 until they
meet — count is mu (length of tail before cycle)
Phase 3: advance fast around cycle once until it meets slow
— count is lam (cycle length)
For x0 = 1, the orbit visits 1, 7, 2, 9, 6, 0, 5, 15 then returns
to 1 — pure cycle of length 8, mu = 0, lam = 8. Encoded as
mu*100 + lam = 8.
Tests three sequential while loops sharing ref state,
double-step `fast := f (f !fast)`, meeting-condition flag.
185 baseline programs total.
This commit is contained in:
@@ -407,6 +407,17 @@ _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 — 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
|
||||
collide inside the cycle, (2) restart slow from x0 and advance
|
||||
both by 1 until they meet — the count is μ (tail length),
|
||||
(3) advance fast around the cycle once until it meets slow — the
|
||||
count is λ (cycle length). For x0=1, f(1)=7, f(7)=2, … cycles
|
||||
through all 8 distinct values 1,7,2,9,6,0,5,15 before returning
|
||||
to 1, so μ=0 λ=8 → 0*100+8=8. Tests three sequential while
|
||||
loops sharing ref state, double-step `fast := f (f !fast)`,
|
||||
meeting-condition flag pattern. 185 baseline programs total.
|
||||
- 2026-05-11 Phase 5.1 — kth_two.ml baseline (8th smallest in
|
||||
merged [1;3;5;7;9;11;13] ∪ [2;4;6;8;10;12] = 8). Two-pointer
|
||||
merge that advances the smaller-head pointer k times. Pick rule:
|
||||
|
||||
Reference in New Issue
Block a user