program = [[ >+++++++++[<++++++++>-]<.>+++++++[<++++>-]<+.+++++++..+++.[-
]>++++++++[<++++>-] <.>+++++++++++[<++++++++>-]<-.--------.+
++.------.--------.[-]>++++++++[<++++>- ]<+.[-]++++++++++.]]
p, counter, marker = 0, 1, 1
cells = {}
for i = 1, 30000 do
cells[i] = 0
end
repeat
local c = string.sub(program, counter, counter)
if c == '>' then
marker = marker + 1
elseif c == '<' and marker ~= 1 then
marker = marker - 1
elseif c == '+' then
cells[marker] = cells[marker] + 1
elseif c == '-' then
if cells[marker] ~= 0 then cells[marker] = cells[marker] - 1 end
elseif c == '[' then
p = counter
elseif c == ']' then
if cells[marker] ~= 0 then counter = p end
elseif c == '.' then
io.write(string.char(cells[marker]))
elseif c == ',' then
cells[marker] = string.byte(io.read())
end
counter = counter + 1
until counter == #program + 1