Data update

This commit is contained in:
Ingy döt Net 2024-07-13 15:19:22 -07:00
parent 29a5eea0d4
commit 5c1bb7bfa9
2011 changed files with 35081 additions and 3229 deletions

View file

@ -0,0 +1,29 @@
function GenBracketExpr(n: integer): string;
begin
var a := Arr('[',']')*n;
Shuffle(a);
Result := a.JoinToString
end;
function IsBalanced(s: string): boolean;
begin
Result := True;
var st := new Stack<char>;
foreach var c in s do
if c = '[' then
st.Push(c)
else if (st.Count > 0) and (st.Peek = '[') then
st.Pop
else begin
Result := False;
exit
end;
end;
begin
loop 10 do
begin
var s := GenBracketExpr(Random(2,5));
Println(s, IsBalanced(s));
end;
end.