Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,17 @@
const Chars:[string] = ["[","]"];
func GenerateString(Amount:number=4):string{
set Result:string = "";
<|(*1..Amount)=>Result+=Chars[math.random(0,?Chars-1)];
send Result;
}
func IsBalanced(String:string):boolean{
set Pairs:number = 0;
<|(*(0..(?String-1)))=>(String::at(_)=="[")?(Pairs<0)?=>send false,Pairs++,=>Pairs--;
send (Opens==Closes)&(Pairs==0);
}
repeat 10 {
set s = GenerateString(math.random(2,4)*2);
log(`{s}: {IsBalanced(s)}`);
}