Data update
This commit is contained in:
parent
5150844a7d
commit
4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions
|
|
@ -1,17 +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;
|
||||
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);
|
||||
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)}`);
|
||||
set s = GenerateString(math.random(2,4)*2);
|
||||
log(`{s}: {IsBalanced(s)}`);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue