def aho(papa)
i = 0
k = 0
l = []
lp = []
while i < papa.length
if papa[i] == "+"
k += 1
elsif papa[i] == "-"
k -= 1
elsif papa[i] == "<"
l << k
k = 0
elsif papa[i] == ">"
k += l.pop
elsif papa[i] == "("
lp << [i,1]
elsif papa[i] == ")"
if lp[-1][1] == 1
lp[-1][1] = 0
i = lp[-1][0]
else
lp.pop
end
elsif papa[i] == ","
k=0
end
i += 1
end
k
end
5.times do
puts aho("(((((((++)-)-<)>>-)<)<)>,>>)")
end
To embed this project on your website, copy the following code and paste it into your website's HTML: