Brainf*ck

Make Brainf*ck interpreter.
Read Brainf*ck code as first line of stdin,
and read input characters as second line of stdin.

http://wikipedia.org/wiki/Brainfuck

Commands

> : inc pointer
< : dec pointer
+ : inc byte
- : dec byte
. : output byte
, : accept one byte
[ : if the byte at the data pointer is zero,
	jump it forward after the matching ] 
] : if the byte at the data pointer is nonzero,
	jump it back after the matching [

IN

+++++++++[>++++++++>+++++++++++>+++++<<<-]>.>++.+++++++..+++.>-.------------.<++++++++.--------.+++.------.--------.>+.
<no input>

OUT

Hello, world!

IN

+++++++++[>++++++++>+++++++++++>+++++<<<-]>.>+-.+++++++..+++.>-.------------.<++++++++.--------.+++.------.--------.>+.
<no input>

OUT

Hcjjm, umpjb!

IN

+++++++++[>++++++++>+++++++++++>+++++<<<-]>.>++.+++-+++..+++.>-.------------.<++++++++.--------.+++.------.--------.>+.
<no input>

OUT

Hejjm, umpjb!

IN

+++++++++[>++++++++>+++++++++++>+++++<<<-]>.>++.+++-+++..+++.>-.----+-------.<++++++++.--------.+++.------.--------.>+.
<no input>

OUT

Hejjm,"umpjb#

IN

+++[>+++<-]>[>,+++.<-]
Brainf*ck

OUT

Eudlqi-fn

IN

+++[>+++<-]>[>,+-+.<-]
Brainf*ck

OUT

Csbjog+dl
Login to submit solution


658 symbols haskell failed test 1 Wrong answer
Hello, world![0,72,100,33]
instead of
Hello, world!
Fri Mar 20 13:49:18 2015 YoshikuniJujo
import Data.Char
l=length
main=getLine>>=b 0[].(,)""
b _ m(_,"")=return m
b p m(r,a:d)=case a of '>'->b(succ p)m(a:r,d);'<'->b(pred p)m(a:r,d);'+'->b p(o succ p m)(a:r,d);'-'->b p(o pred p m)(a:r,d);'.'->putChar(chr$m!!p)>>b p m(a:r,d);','->do{c<-getChar;b p(o(const$ord c)p m)(a:r,d)};'['|l m<p+1||m!!p==0->b p m.k 1$(a:r,d)|0<1->b p m(a:r,d); ']'|m!!p/=0->b p m.t 1$(r,a:d)|0<1->b p m(a:r,d);
o f p m|l m<p+1=o f p$m++replicate(p+1-l m)0|0<1=take p m++[f$m!!p]++drop(p+1)m
k n p|n<1=p
k n(r,'[':s)=k(n+1)('[':r,s)
k n(r,']':s)=k(n-1)(']':r,s)
k n(r,c:s)=k n(c:r,s)
t n p|n<1=p
t n(']':r,s)=t(n+1)(r,']':s)
t n('[':r,s)=t(n-1)(r,'[':s)
t n(c:r,s)=t n(r,c:s)
288 symbols python3 failed test 1 Code error

Traceback (most recent call last): File "./code", line 15, in <module> eval(e) File "<string>", line 2 i=0 ^ SyntaxError: invalid syntax

Thu Oct 8 20:01:40 2015 BogdanShevchenko
s=input()
j=input()
p="""
"""
t="    "
n=0
e='''
i=0
a=[0 for I in range(30000)]
'''
d={'>':"i+=1",'<':"i-=1",'+':"a[i]+=1",'-':"arr[i]-=1",'.':"print(chr(arr[i]))",',':"""arr[i]=ord(j[k])
k+=1""",'[':"while arr[i]:",']':""}
r={'[':1,']':-1}
for c in s:e+=t*n+d[c]+p;n+=r.get(c,0)
eval(e)
291 symbols python3 failed test 1 Code error

Traceback (most recent call last): File "./code", line 1, in <module> s=raw_input() NameError: name 'raw_input' is not defined

Thu Oct 8 20:06:56 2015 BogdanShevchenko
s=raw_input()
j=raw_input()
p="""
"""
t="    "
n=0
e='''
i=0
a=[0 for I in range(30000)]
'''
d={'>':"i+=1",'<':"i-=1",'+':"a[i]+=1",'-':"arr[i]-=1",'.':"print(chr(a[i]))",',':"""a[i]=ord(j[k])
k+=1""",'[':"while a[i]:",']':""}
r={'[':1,']':-1}
for c in s:e+=t*n+d[c]+p;n+=r.get(c,0)
print(e)
283 symbols python3 failed test 1 Wrong answer
i=0
a=[0 for I in range(30000)]
a[i]+=1
a[i]+=1
a[i]+=1
a[i]+=1
a[i]+=1
a[i]+=1
a[i]+=1
a[i]+=1
a[i]+=1
while a[i]:
    i+=1
    a[i]+=1
    a[i]+=1
    a[i]+=1
    a[i]+=1
    a[i]+=1
    a[i]+=1
    a[i]+=1
    a[i]+=1
    i+=1
    a[i]+=1
    a[i]+=1
    a[i]+=1
    a[i]+=1
    a[i]+=1
    a[i]+=1
    a[i]+=1
    a[i]+=1
    a[i]+=1
    a[i]+=1
    a[i]+=1
    i+=1
    a[i]+=1
    a[i]+=1
    a[i]+=1
    a[i]+=1
    a[i]+=1
    i-=1
    i-=1
    i-=1
    arr[i]-=1
    
i+=1
print(chr(a[i]))
i+=1
a[i]+=1
a[i]+=1
print(chr(a[i]))
a[i]+=1
a[i]+=1
a[i]+=1
a[i]+=1
a[i]+=1
a[i]+=1
a[i]+=1
print(chr(a[i]))
print(chr(a[i]))
a[i]+=1
a[i]+=1
a[i]+=1
print(chr(a[i]))
i+=1
arr[i]-=1
print(chr(a[i]))
arr[i]-=1
arr[i]-=1
arr[i]-=1
arr[i]-=1
arr[i]-=1
arr[i]-=1
arr[i]-=1
arr[i]-=1
arr[i]-=1
arr[i]-=1
arr[i]-=1
arr[i]-=1
print(chr(a[i]))
i-=1
a[i]+=1
a[i]+=1
a[i]+=1
a[i]+=1
a[i]+=1
a[i]+=1
a[i]+=1
a[i]+=1
print(chr(a[i]))
arr[i]-=1
arr[i]-=1
arr[i]-=1
arr[i]-=1
arr[i]-=1
arr[i]-=1
arr[i]-=1
arr[i]-=1
print(chr(a[i]))
a[i]+=1
a[i]+=1
a[i]+=1
print(chr(a[i]))
arr[i]-=1
arr[i]-=1
arr[i]-=1
arr[i]-=1
arr[i]-=1
arr[i]-=1
print(chr(a[i]))
arr[i]-=1
arr[i]-=1
arr[i]-=1
arr[i]-=1
arr[i]-=1
arr[i]-=1
arr[i]-=1
arr[i]-=1
print(chr(a[i]))
i+=1
a[i]+=1
print(chr(a[i]))
instead of
Hello, world!
Thu Oct 8 20:07:38 2015 BogdanShevchenko
s=input()
j=input()
p="""
"""
t="    "
n=0
e='''
i=0
a=[0 for I in range(30000)]
'''
d={'>':"i+=1",'<':"i-=1",'+':"a[i]+=1",'-':"arr[i]-=1",'.':"print(chr(a[i]))",',':"""a[i]=ord(j[k])
k+=1""",'[':"while a[i]:",']':""}
r={'[':1,']':-1}
for c in s:e+=t*n+d[c]+p;n+=r.get(c,0)
print(e)
281 symbols python3 failed test 1 Wrong answer
i=0
a=[0 for I in range(30000)]
a[i]+=1
a[i]+=1
a[i]+=1
a[i]+=1
a[i]+=1
a[i]+=1
a[i]+=1
a[i]+=1
a[i]+=1
while a[i]:
    i+=1
    a[i]+=1
    a[i]+=1
    a[i]+=1
    a[i]+=1
    a[i]+=1
    a[i]+=1
    a[i]+=1
    a[i]+=1
    i+=1
    a[i]+=1
    a[i]+=1
    a[i]+=1
    a[i]+=1
    a[i]+=1
    a[i]+=1
    a[i]+=1
    a[i]+=1
    a[i]+=1
    a[i]+=1
    a[i]+=1
    i+=1
    a[i]+=1
    a[i]+=1
    a[i]+=1
    a[i]+=1
    a[i]+=1
    i-=1
    i-=1
    i-=1
    a[i]-=1
    
i+=1
print(chr(a[i]))
i+=1
a[i]+=1
a[i]+=1
print(chr(a[i]))
a[i]+=1
a[i]+=1
a[i]+=1
a[i]+=1
a[i]+=1
a[i]+=1
a[i]+=1
print(chr(a[i]))
print(chr(a[i]))
a[i]+=1
a[i]+=1
a[i]+=1
print(chr(a[i]))
i+=1
a[i]-=1
print(chr(a[i]))
a[i]-=1
a[i]-=1
a[i]-=1
a[i]-=1
a[i]-=1
a[i]-=1
a[i]-=1
a[i]-=1
a[i]-=1
a[i]-=1
a[i]-=1
a[i]-=1
print(chr(a[i]))
i-=1
a[i]+=1
a[i]+=1
a[i]+=1
a[i]+=1
a[i]+=1
a[i]+=1
a[i]+=1
a[i]+=1
print(chr(a[i]))
a[i]-=1
a[i]-=1
a[i]-=1
a[i]-=1
a[i]-=1
a[i]-=1
a[i]-=1
a[i]-=1
print(chr(a[i]))
a[i]+=1
a[i]+=1
a[i]+=1
print(chr(a[i]))
a[i]-=1
a[i]-=1
a[i]-=1
a[i]-=1
a[i]-=1
a[i]-=1
print(chr(a[i]))
a[i]-=1
a[i]-=1
a[i]-=1
a[i]-=1
a[i]-=1
a[i]-=1
a[i]-=1
a[i]-=1
print(chr(a[i]))
i+=1
a[i]+=1
print(chr(a[i]))
instead of
Hello, world!
Thu Oct 8 20:08:50 2015 BogdanShevchenko
s=input()
j=input()
p="""
"""
t="    "
n=0
e='''
i=0
a=[0 for I in range(30000)]
'''
d={'>':"i+=1",'<':"i-=1",'+':"a[i]+=1",'-':"a[i]-=1",'.':"print(chr(a[i]))",',':"""a[i]=ord(j[k])
k+=1""",'[':"while a[i]:",']':""}
r={'[':1,']':-1}
for c in s:e+=t*n+d[c]+p;n+=r.get(c,0)
print(e)
280 symbols python3 failed test 1 Code error

Traceback (most recent call last): File "./code", line 15, in <module> eval(e) File "<string>", line 2 i=0 ^ SyntaxError: invalid syntax

Thu Oct 8 20:09:47 2015 BogdanShevchenko
s=input()
j=input()
p="""
"""
t="    "
n=0
e='''
i=0
a=[0 for I in range(30000)]
'''
d={'>':"i+=1",'<':"i-=1",'+':"a[i]+=1",'-':"a[i]-=1",'.':"print(chr(a[i]))",',':"""a[i]=ord(j[k])
k+=1""",'[':"while a[i]:",']':""}
r={'[':1,']':-1}
for c in s:e+=t*n+d[c]+p;n+=r.get(c,0)
eval(e)
275 symbols python3 failed test 1 Code error

Traceback (most recent call last): File "./code", line 14, in <module> eval(e) File "<string>", line 1 a[i]+=1 ^ SyntaxError: invalid syntax

Thu Oct 8 20:10:56 2015 BogdanShevchenko
s=input()
j=input()
p="""
"""
t="    "
n=0
i=0
a=[0 for I in range(30000)]
e=''
d={'>':"i+=1",'<':"i-=1",'+':"a[i]+=1",'-':"a[i]-=1",'.':"print(chr(a[i]))",',':"""a[i]=ord(j[k])
k+=1""",'[':"while a[i]:",']':""}
r={'[':1,']':-1}
for c in s:e+=t*n+d[c]+p;n+=r.get(c,0)
eval(e)
280 symbols python3 failed test 1 Wrong answer
H
e
l
l
o
,
 
w
o
r
l
d
!
instead of
Hello, world!
Thu Oct 8 20:29:28 2015 BogdanShevchenko
s=input()
j=input()
p="""
"""
t="    "
n=0
e='''
i=0
a=[0 for I in range(30000)]
'''
d={'>':"i+=1",'<':"i-=1",'+':"a[i]+=1",'-':"a[i]-=1",'.':"print(chr(a[i]))",',':"""a[i]=ord(j[k])
k+=1""",'[':"while a[i]:",']':""}
r={'[':1,']':-1}
for c in s:e+=t*n+d[c]+p;n+=r.get(c,0)
exec(e)
290 symbols python3 failed test 5 Code error

Traceback (most recent call last): File "./code", line 16, in <module> exec(e) File "<string>", line 21 a[i]+=1 ^ IndentationError: unexpected indent

Thu Oct 8 20:32:13 2015 BogdanShevchenko
s=input()
j=input()
p="""
"""
t="    "
n=0
e='''
i=0
w=""
a=[0 for I in range(30000)]
'''
d={'>':"i+=1",'<':"i-=1",'+':"a[i]+=1",'-':"a[i]-=1",'.':"w+=chr(a[i])",',':"""a[i]=ord(j[k])
k+=1""",'[':"while a[i]:",']':""}
r={'[':1,']':-1}
for c in s:e+=t*n+d[c]+p;n+=r.get(c,0)
exec(e)
print(w)
288 symbols python3 failed test 5 Code error

Traceback (most recent call last): File "./code", line 15, in <module> exec(e) File "<string>", line 20 a[i]+=1 ^ IndentationError: unexpected indent

Thu Oct 8 20:37:26 2015 BogdanShevchenko
s=input()
j=input()
p="""
"""
t="    "
n=0
e='''
i=0
a=[0 for I in range(30000)]
'''
d={'>':"i+=1",'<':"i-=1",'+':"a[i]+=1",'-':"a[i]-=1",'.':"print(chr(a[i]), end='')",',':"""a[i]=ord(j[k])
k+=1""",'[':"while a[i]:",']':""}
r={'[':1,']':-1}
for c in s:e+=t*n+d[c]+p;n+=r.get(c,0)
exec(e)
280 symbols python3 failed test 1 Wrong answer
H
e
l
l
o
,
 
w
o
r
l
d
!
instead of
Hello, world!
Thu Oct 8 20:37:55 2015 BogdanShevchenko
s=input()
j=input()
p="""
"""
t="    "
n=0
e='''
i=0
a=[0 for I in range(30000)]
'''
d={'>':"i+=1",'<':"i-=1",'+':"a[i]+=1",'-':"a[i]-=1",'.':"print(chr(a[i]))",',':"""a[i]=ord(j[k])
k+=1""",'[':"while a[i]:",']':""}
r={'[':1,']':-1}
for c in s:e+=t*n+d[c]+p;n+=r.get(c,0)
exec(e)
288 symbols python3 failed test 1 Code error

Traceback (most recent call last): File "./code", line 15, in <module> exec(e) File "<string>", line 47 print(chr(a[i]), end=) ^ SyntaxError: invalid syntax

Thu Oct 8 20:38:34 2015 BogdanShevchenko
s=input()
j=input()
p="""
"""
t="    "
n=0
e='''
i=0
a=[0 for I in range(30000)]
'''
d={'>':"i+=1",'<':"i-=1",'+':"a[i]+=1",'-':"a[i]-=1",'.':"print(chr(a[i]), end="")",',':"""a[i]=ord(j[k])
k+=1""",'[':"while a[i]:",']':""}
r={'[':1,']':-1}
for c in s:e+=t*n+d[c]+p;n+=r.get(c,0)
exec(e)
288 symbols python3 failed test 5 Code error

Traceback (most recent call last): File "./code", line 15, in <module> exec(e) File "<string>", line 20 a[i]+=1 ^ IndentationError: unexpected indent

Thu Oct 8 20:39:20 2015 BogdanShevchenko
s=input()
j=input()
p="""
"""
t="    "
n=0
e='''
i=0
a=[0 for I in range(30000)]
'''
d={'>':"i+=1",'<':"i-=1",'+':"a[i]+=1",'-':"a[i]-=1",'.':"print(chr(a[i]), end='')",',':"""a[i]=ord(j[k])
k+=1""",'[':"while a[i]:",']':""}
r={'[':1,']':-1}
for c in s:e+=t*n+d[c]+p;n+=r.get(c,0)
exec(e)
292 symbols python3 failed test 5 Code error

Traceback (most recent call last): File "./code", line 15, in <module> exec(e) File "<string>", line 20 a[i]+=1 ^ IndentationError: unexpected indent

Thu Oct 8 20:41:54 2015 BogdanShevchenko
s=input()
j=input()
p="""
"""
t="    "
n=0
e='''
i=0
a=[0 for I in range(30000)]
'''
d={'>':"i+=1",'<':"i-=1",'+':"a[i]+=1",'-':"a[i]-=1",'.':'''print(chr(a[i]), end="")''',',':"""a[i]=ord(j[k])
k+=1""",'[':"while a[i]:",']':""}
r={'[':1,']':-1}
for c in s:e+=t*n+d[c]+p;n+=r.get(c,0)
exec(e)
293 symbols python3 failed test 1 Wrong answer
i=0
a=[0 for I in range(30000)]
a[i]+=1
a[i]+=1
a[i]+=1
a[i]+=1
a[i]+=1
a[i]+=1
a[i]+=1
a[i]+=1
a[i]+=1
while a[i]:
    i+=1
    a[i]+=1
    a[i]+=1
    a[i]+=1
    a[i]+=1
    a[i]+=1
    a[i]+=1
    a[i]+=1
    a[i]+=1
    i+=1
    a[i]+=1
    a[i]+=1
    a[i]+=1
    a[i]+=1
    a[i]+=1
    a[i]+=1
    a[i]+=1
    a[i]+=1
    a[i]+=1
    a[i]+=1
    a[i]+=1
    i+=1
    a[i]+=1
    a[i]+=1
    a[i]+=1
    a[i]+=1
    a[i]+=1
    i-=1
    i-=1
    i-=1
    a[i]-=1
    
i+=1
print(chr(a[i]), end="")
i+=1
a[i]+=1
a[i]+=1
print(chr(a[i]), end="")
a[i]+=1
a[i]+=1
a[i]+=1
a[i]+=1
a[i]+=1
a[i]+=1
a[i]+=1
print(chr(a[i]), end="")
print(chr(a[i]), end="")
a[i]+=1
a[i]+=1
a[i]+=1
print(chr(a[i]), end="")
i+=1
a[i]-=1
print(chr(a[i]), end="")
a[i]-=1
a[i]-=1
a[i]-=1
a[i]-=1
a[i]-=1
a[i]-=1
a[i]-=1
a[i]-=1
a[i]-=1
a[i]-=1
a[i]-=1
a[i]-=1
print(chr(a[i]), end="")
i-=1
a[i]+=1
a[i]+=1
a[i]+=1
a[i]+=1
a[i]+=1
a[i]+=1
a[i]+=1
a[i]+=1
print(chr(a[i]), end="")
a[i]-=1
a[i]-=1
a[i]-=1
a[i]-=1
a[i]-=1
a[i]-=1
a[i]-=1
a[i]-=1
print(chr(a[i]), end="")
a[i]+=1
a[i]+=1
a[i]+=1
print(chr(a[i]), end="")
a[i]-=1
a[i]-=1
a[i]-=1
a[i]-=1
a[i]-=1
a[i]-=1
print(chr(a[i]), end="")
a[i]-=1
a[i]-=1
a[i]-=1
a[i]-=1
a[i]-=1
a[i]-=1
a[i]-=1
a[i]-=1
print(chr(a[i]), end="")
i+=1
a[i]+=1
print(chr(a[i]), end="")
instead of
Hello, world!
Thu Oct 8 20:42:32 2015 BogdanShevchenko
s=input()
j=input()
p="""
"""
t="    "
n=0
e='''
i=0
a=[0 for I in range(30000)]
'''
d={'>':"i+=1",'<':"i-=1",'+':"a[i]+=1",'-':"a[i]-=1",'.':'''print(chr(a[i]), end="")''',',':"""a[i]=ord(j[k])
k+=1""",'[':"while a[i]:",']':""}
r={'[':1,']':-1}
for c in s:e+=t*n+d[c]+p;n+=r.get(c,0)
print(e)
281 symbols python3 failed test 1 Wrong answer
H
e
l
l
o
,
 
w
o
r
l
d
!
instead of
Hello, world!
Thu Oct 8 20:47:14 2015 BogdanShevchenko
s=input()
j=input()
p="""
"""
t="    "
n=0
e='''
i=0
a=[0 for I in range(30000)]
'''
d={'>':"i+=1",'<':"i-=1",'+':"a[i]+=1",'-':"a[i]-=1",'.':"print(chr(a[i]),)",',':"""a[i]=ord(j[k])
k+=1""",'[':"while a[i]:",']':""}
r={'[':1,']':-1}
for c in s:e+=t*n+d[c]+p;n+=r.get(c,0)
exec(e)
282 symbols python3 failed test 1 Wrong answer
w=""
i=0
a=[0 for I in range(30000)]
a[i]+=1
a[i]+=1
a[i]+=1
a[i]+=1
a[i]+=1
a[i]+=1
a[i]+=1
a[i]+=1
a[i]+=1
while a[i]:
    i+=1
    a[i]+=1
    a[i]+=1
    a[i]+=1
    a[i]+=1
    a[i]+=1
    a[i]+=1
    a[i]+=1
    a[i]+=1
    i+=1
    a[i]+=1
    a[i]+=1
    a[i]+=1
    a[i]+=1
    a[i]+=1
    a[i]+=1
    a[i]+=1
    a[i]+=1
    a[i]+=1
    a[i]+=1
    a[i]+=1
    i+=1
    a[i]+=1
    a[i]+=1
    a[i]+=1
    a[i]+=1
    a[i]+=1
    i-=1
    i-=1
    i-=1
    a[i]-=1
    
i+=1
w+=chr(a[i])
i+=1
a[i]+=1
a[i]+=1
w+=chr(a[i])
a[i]+=1
a[i]+=1
a[i]+=1
a[i]+=1
a[i]+=1
a[i]+=1
a[i]+=1
w+=chr(a[i])
w+=chr(a[i])
a[i]+=1
a[i]+=1
a[i]+=1
w+=chr(a[i])
i+=1
a[i]-=1
w+=chr(a[i])
a[i]-=1
a[i]-=1
a[i]-=1
a[i]-=1
a[i]-=1
a[i]-=1
a[i]-=1
a[i]-=1
a[i]-=1
a[i]-=1
a[i]-=1
a[i]-=1
w+=chr(a[i])
i-=1
a[i]+=1
a[i]+=1
a[i]+=1
a[i]+=1
a[i]+=1
a[i]+=1
a[i]+=1
a[i]+=1
w+=chr(a[i])
a[i]-=1
a[i]-=1
a[i]-=1
a[i]-=1
a[i]-=1
a[i]-=1
a[i]-=1
a[i]-=1
w+=chr(a[i])
a[i]+=1
a[i]+=1
a[i]+=1
w+=chr(a[i])
a[i]-=1
a[i]-=1
a[i]-=1
a[i]-=1
a[i]-=1
a[i]-=1
w+=chr(a[i])
a[i]-=1
a[i]-=1
a[i]-=1
a[i]-=1
a[i]-=1
a[i]-=1
a[i]-=1
a[i]-=1
w+=chr(a[i])
i+=1
a[i]+=1
w+=chr(a[i])
instead of
Hello, world!
Thu Oct 8 20:48:30 2015 BogdanShevchenko
s=input()
j=input()
p="""
"""
t="    "
n=0
e='''
w=""
i=0
a=[0 for I in range(30000)]
'''
d={'>':"i+=1",'<':"i-=1",'+':"a[i]+=1",'-':"a[i]-=1",'.':"w+=chr(a[i])",',':"""a[i]=ord(j[k])
k+=1""",'[':"while a[i]:",']':""}
r={'[':1,']':-1}
for c in s:e+=t*n+d[c]+p;n+=r.get(c,0)
print(e)
281 symbols python3 failed test 1 Wrong answer

                      
instead of
Hello, world!
Thu Oct 8 20:49:30 2015 BogdanShevchenko
s=input()
j=input()
p="""
"""
t="    "
n=0
e='''
w=""
i=0
a=[0 for I in range(30000)]
'''
d={'>':"i+=1",'<':"i-=1",'+':"a[i]+=1",'-':"a[i]-=1",'.':"w+=chr(a[i])",',':"""a[i]=ord(j[k])
k+=1""",'[':"while a[i]:",']':""}
r={'[':1,']':-1}
for c in s:e+=t*n+d[c]+p;n+=r.get(c,0)
exec(e)
294 symbols python3 failed test 5 Code error

Traceback (most recent call last): File "./code", line 16, in <module> exec(e+p+'print(w)') File "<string>", line 21 a[i]+=1 ^ IndentationError: unexpected indent

Thu Oct 8 20:50:57 2015 BogdanShevchenko
s=input()
j=input()
p="""
"""
t="    "
n=0
e='''
w=""
i=0
a=[0 for I in range(30000)]
'''
d={'>':"i+=1",'<':"i-=1",'+':"a[i]+=1",'-':"a[i]-=1",'.':"w+=chr(a[i])",',':"""a[i]=ord(j[k])
k+=1""",'[':"while a[i]:",']':""}
r={'[':1,']':-1}
for c in s:e+=t*n+d[c]+p;n+=r.get(c,0)
exec(e+p+'print(w)')
283 symbols python3 failed test 1 Wrong answer

                      
instead of
Hello, world!
Thu Oct 8 20:52:41 2015 BogdanShevchenko
s=input()
j=input()
p="""
"""
t="    "
n=0
e='''
w=""
i=0
a=[0 for I in range(30000)]
'''
d={'>':"i+=1",'<':"i-=1",'+':"a[i]+=1",'-':"a[i]-=1",'.':"w+=chr(a[i])",',':"""a[i]=ord(j[k])
k+=1""",'[':"while a[i]:",']':""}
r={'[':1,']':-1}
for c in s:e+=t*n+d[c]+p;n+=r.get(c,0)
exec(e+p)

View all solutions