ocaml: phase 5.1 bracket_match.ml baseline (5/9 balanced strings)
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
Stack-based multi-bracket parenthesis matching for ( [ { ) ] }.
Non-bracket chars are skipped (treated as content).
Tests:
() yes
[{()}] yes
({[}]) no (mismatched closer)
"" yes
(( no (unclosed)
()[](){} yes
(a(b)c) yes (a/b/c skipped)
(() no
]) no
5 balanced
Body uses begin/end-wrapped match inside while:
else if c = ')' || c = ']' || c = '}' then begin
match !stack with
| [] -> ok := false
| top :: rest ->
let pair =
(c = ')' && top = '(') ||
(c = ']' && top = '[') ||
(c = '}' && top = '{')
in
if pair then stack := rest else ok := false
end
Tests side-effecting match arms inside while body, ref-of-list as
stack, multi-char pairing dispatch.
174 baseline programs total.
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
"bipartite.ml": 4,
|
||||
"bits.ml": 21,
|
||||
"balance.ml": 3,
|
||||
"bracket_match.ml": 5,
|
||||
"base_n.ml": 17,
|
||||
"bfs.ml": 6,
|
||||
"bfs_grid.ml": 8,
|
||||
|
||||
Reference in New Issue
Block a user