Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,9 @@
|
|||
isBalanced = function(str)
|
||||
level = 0
|
||||
for c in str
|
||||
if c == "[" then level = level + 1
|
||||
if c == "]" then level = level - 1
|
||||
if level < 0 then return false
|
||||
end for
|
||||
return level == 0
|
||||
end function
|
||||
15
Task/Balanced-brackets/MiniScript/balanced-brackets-2.mini
Normal file
15
Task/Balanced-brackets/MiniScript/balanced-brackets-2.mini
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
examples = [
|
||||
"",
|
||||
"[]",
|
||||
"[][]",
|
||||
"[[][]]",
|
||||
"][",
|
||||
"][][",
|
||||
"[]][[]",
|
||||
"[[[]"]
|
||||
|
||||
for str in examples
|
||||
balanced = isBalanced(str)
|
||||
if balanced then outcome = "is OK" else outcome = "NOT OK"
|
||||
print """" + str + """ " + outcome
|
||||
end for
|
||||
Loading…
Add table
Add a link
Reference in a new issue