Files
rose-ash/lib/ocaml/baseline/expected.json
giles 97a8c06690
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 51s
ocaml: phase 5.1 balance.ml baseline (paren/bracket/brace balance via Stack)
is_balanced walks a string; on each char:
  '(', '[', '{'  -> Stack.push c
  ')', ']', '}'  -> require stack non-empty AND top = expected opener,
                     else mark ok = false
  others         -> skip

At end: !ok && Stack.is_empty stack.

Five test cases:
  '({[abc]d}e)'  -> true
  '(a]'           -> false  (no matching opener)
  '{[}]'          -> false  (mismatched closer)
  '(())'          -> true
  ''              -> true

Sum of (if balanced then 1 else 0) -> 3.

Exercises:
  Stack.create / push / pop / is_empty
  s.[!i] string indexing
  while loop + bool ref short-circuit
  multi-arm if/else if/else if dispatch

31 baseline programs total.
2026-05-09 06:59:22 +00:00

36 lines
702 B
JSON

{
"anagrams.ml": 3,
"bag.ml": 3,
"balance.ml": 3,
"bfs.ml": 6,
"btree.ml": 39,
"brainfuck.ml": 75,
"caesar.ml": 215,
"calc.ml": 13,
"closures.ml": 315,
"csv.ml": 10,
"exception_handle.ml": 4,
"expr_eval.ml": 16,
"factorial.ml": 3628800,
"fraction.ml": 7,
"frequency.ml": 5,
"fizzbuzz.ml": 57,
"list_ops.ml": 30,
"lambda_calc.ml": 7,
"levenshtein.ml": 11,
"memo_fib.ml": 75025,
"merge_sort.ml": 44,
"module_use.ml": 3,
"mutable_record.ml": 10,
"option_match.ml": 5,
"poly_stack.ml": 5,
"queens.ml": 2,
"quicksort.ml": 44,
"roman.ml": 44,
"safe_div.ml": 20,
"sieve.ml": 15,
"sum_squares.ml": 385,
"unique_set.ml": 9,
"word_count.ml": 3
}