Skip to content

Instantly share code, notes, and snippets.

@boxmein
Last active December 24, 2015 02:19
Show Gist options
  • Save boxmein/6729923 to your computer and use it in GitHub Desktop.
Save boxmein/6729923 to your computer and use it in GitHub Desktop.
#powder fuckfuck/brainfuck clone. This kept me busy for a few minutes.
import sys, array
# Name to character reference
# you can like
# modify me
# modify me a lot
# i likes it
ch = {
'mniip': '<',
'Ristovski': '>',
'Catelite': '+',
'MiningMarsh': '-',
'jacob1': '[',
'Ximon': ']',
'Fast-Driver': '.',
'Triclops200': ',' # ugh i couldn't think of anyone
}
def effify (stream):
buf = ""
for line in stream:
# i dun like whitespace
line = line.strip()
for word in line.split():
# yay words
if not (word in ch):
print("Line had invalid word '" + word + "'\n"+line)
break
# this is brainfuck
buf += ch[word]
print (buf)
return buf
if __name__ == '__main__':
if len(sys.argv) < 2 or sys.argv[1] == '-h' or sys.argv[1] == '--help':
print ('''
#powder -> Brainfuck converter :D
Usage:
python tptbf.py <file> -> generates the code in <file>
python tptbf.py -h | --help -> displays me
Use case count:
0
Usability factor:
0
Usefulness factor:
-1
by boxmein, 2013. public domain''')
exit(0)
with open(sys.argv[1], 'r') as f:
code = effify(f)
# #powder -> brainfuck converter!
# kinda builds upon the ideas of fuckfuck
# and makes it strange
# paste the code from it into #powder
# i dare you
# alternatively pipe the output into bf
# boxmein 2013
# Example source:
# Catelite Catelite Catelite Catelite Catelite Catelite jacob1 Ristovski Catelite
# Catelite Catelite Catelite Catelite Catelite Catelite Catelite Catelite Catelite
# mniip MiningMarsh Ximon Ristovski Catelite Catelite Catelite Catelite Catelite Fast-Driver Triclops200
# Brainfuck code for if you need an interpreter:
# gcc -o bf below.c [-lmingw32]
# #include <stdlib.h>
# char m[9999],*n[99],*r=m,*p=m+5000,**s=n,d,c;main(){for(read(0,r,4000);c=*r;
# r++)c-']'||(d>1||(r=*p?*s:(--s,r)),!d||d--),c-'['||d++||(*++s=r),d||(*p+=c==
# '+',*p-=c=='-',p+=c=='>',p-=c=='<',c-'.'||write(2,p,1),c-','||read(2,p,1));}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment