Skip to content

Instantly share code, notes, and snippets.

@arifsuhan
Created February 27, 2018 19:13
Show Gist options
  • Save arifsuhan/52c547336198a198b35ea605889790e6 to your computer and use it in GitHub Desktop.
Save arifsuhan/52c547336198a198b35ea605889790e6 to your computer and use it in GitHub Desktop.
BrainF*ck
def loopRunner(loop,endChar):
s=""
for i in loop:
s+=">"
for j in range(0,i):
s+="+"
s+=endChar+"\n"
return s
def backToHead(stack):
s=""
for i in range(0,len(stack)):
s+="<"
s+="-\n]\n"
return s
print("")
print("---------------------------")
print("Print any Text in BrainF*ck")
print("---------------------------")
print("Type text and Get the Code")
text=input(":")
loop="++++++++++\n[\n"
innerLoop=[]
outerLoop=[]
for i in text:
innerLoop.append(int(ord(i)/10))
outerLoop.append(ord(i)%10)
fullCode=""
fullCode=loop+loopRunner(innerLoop,"")+backToHead(innerLoop)+loopRunner(outerLoop,".")
file=open("a.txt","w")
print(fullCode)
file.write(fullCode)
file.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment