Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
21
Task/Balanced-brackets/Phix/balanced-brackets.phix
Normal file
21
Task/Balanced-brackets/Phix/balanced-brackets.phix
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
function check_brackets(sequence s)
|
||||
integer level = 0
|
||||
for i=1 to length(s) do
|
||||
switch s[i]
|
||||
case '[': level += 1
|
||||
case ']': level -= 1
|
||||
if level<0 then exit end if
|
||||
end switch
|
||||
end for
|
||||
return (level=0)
|
||||
end function
|
||||
|
||||
sequence s
|
||||
constant ok = {"not ok","ok"}
|
||||
|
||||
for i=1 to 10 do
|
||||
for j=1 to 2 do
|
||||
s = shuffle(join(repeat("[]",i-1),""))
|
||||
printf(1,"%s %s\n",{s,ok[check_brackets(s)+1]})
|
||||
end for
|
||||
end for
|
||||
Loading…
Add table
Add a link
Reference in a new issue