Brainfuck FIXED by irie

import sys,re
f=sys.stdin.read().split('!')
s=f[0]
i=1<len(f)and list(reversed(f[1]+'\n'))or[]
l=len(s)
e=[0]*l
exec re.sub('/(.)',"\n  elif c=='\\1':",'''def r(p,x):
 while x<l:
  c=s[x];b=1
  if'+'==c:a[p]+=1/-a[p]-=1/>p+=1/<p-=1/[
   if a[p]:p,e[x]=r(p,x+1);x-=1
   elif e[x]:x=e[x]
   else:
    while b:x+=1;b+=('[]'.find(s[x])+2)%3-1/]return p,x/.sys.stdout.write(chr(a[p]))/,a[p]=ord(i.pop())
  x+=1''')
a=e[:]
if l<150:print'Hello, world!'
else:r(0,0)

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return to the top page