Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
24
Task/Balanced-brackets/Arturo/balanced-brackets.arturo
Normal file
24
Task/Balanced-brackets/Arturo/balanced-brackets.arturo
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
isBalanced: function [s][
|
||||
cnt: 0
|
||||
|
||||
loop split s [ch][
|
||||
if? ch="]" [
|
||||
cnt: cnt-1
|
||||
if cnt<0 -> return false
|
||||
]
|
||||
else [
|
||||
if ch="[" -> cnt: cnt+1
|
||||
]
|
||||
]
|
||||
|
||||
cnt=0
|
||||
]
|
||||
|
||||
loop 1..10 'i [
|
||||
str: join map 0..(2*i)-1 [x][ sample ["[" "]"]]
|
||||
|
||||
prints str
|
||||
|
||||
if? isBalanced str -> print " OK"
|
||||
else -> print " Not OK"
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue