ocaml: phase 5.1 palindrome.ml baseline (two-pointer check, 4/6 inputs match)
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
Two-pointer palindrome check:
let is_palindrome s =
let n = String.length s in
let rec check i j =
if i >= j then true
else if s.[i] <> s.[j] then false
else check (i + 1) (j - 1)
in
check 0 (n - 1)
Tests on six strings:
racecar = true
hello = false
abba = true
'' = true (vacuously, i >= j on entry)
'a' = true
'ab' = false
Sum = 4.
Uses s.[i] <> s.[j] (string-get + structural inequality), recursive
2-arg pointer advancement, and a multi-clause if/else if/else for
the three cases.
48 baseline programs total.
This commit is contained in:
@@ -407,6 +407,13 @@ _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-09 Phase 5.1 — palindrome.ml baseline (two-pointer
|
||||
palindrome check, 4 of 6 inputs are palindromes). is_palindrome
|
||||
walks from both ends meeting in the middle, returning false on
|
||||
first mismatch. Tests on six strings (racecar ✓, hello ✗, abba ✓,
|
||||
"" ✓, "a" ✓, "ab" ✗) sum to 4. Uses `s.[i] <> s.[j]` (string-get
|
||||
+ structural inequality) and recursive 2-arg pointer advancement.
|
||||
48 baseline programs total.
|
||||
- 2026-05-09 Phase 5.1 — coin_change.ml baseline (min coin DP, 67¢
|
||||
with [1;5;10;25] → 6 coins). Bottom-up DP: `dp[i]` = min coins
|
||||
for amount i. For each amount 1..target, iterate coins and
|
||||
|
||||
Reference in New Issue
Block a user