nyuuzyou/wikis huggingface dataset:
Brainfuck Python interpreter

:
The following is an interpreter by User:None1 in Python for brainfuck (supports wraps, EOF returns 0):
import sys
def bf(code):
 s=[]
 matches={}
 tape=[0]*1000000
 for i,j in enumerate(code):
 if j=='[':
 s.append(i)
 if j==']':
 m=s.pop()
 matches[m]=i
 matches[i]=m
 cp=0
 p=0
 while cp<len(code):
 if code[cp]=='+':
 tape[p]=(tape[p]+1)%256
 if code[cp]=='-':
 tape[p]=(tape[p]-1)%256
 if code[cp]==',':
 c=sys.stdin.read(1)
 tape[p]=(ord(c) if c else 0)%256
 if code[cp]=='.':
 print(chr(tape[p]),end=)
 if code[cp]=='<':
 p-=1
 if code[cp]=='>':
 p+=1
 if code[cp]=='[':
 if not tape[p]:
 cp=matches[cp]
 if code[cp]==']':
 if tape[p]:
 cp=matches[cp]
 cp+=1
bf(sys.stdin.read())
The version used by Brainfuck speed test is slightly modified to support source code from a file:
import sys
def bf(code):
 s1=[]
 s2=[]
 matches={}
 tape=[0]*1000000
 for i,j in enumerate(code):
 if j=='[':
 s1.append(i)
 if j==']':
 m=s1.pop()
 matches[m]=i
 matches[i]=m
 cp=0
 p=0
 while cp<len(code):
 if code[cp]=='+':
 tape[p]=(tape[p]+1)%256
 if code[cp]=='-':
 tape[p]=(tape[p]-1)%256
 if code[cp]==',':
 tape[p]=ord(sys.stdin.read(1))%256
 if code[cp]=='.':
 print(chr(tape[p]),end=)
 if code[cp]=='<':
 p-=1
 if code[cp]=='>':
 p+=1
 if code[cp]=='[':
 if not tape[p]:
 cp=matches[cp]
 if code[cp]==']':
 if tape[p]:
 cp=matches[cp]
 cp+=1
fn=sys.argv[1]
bf(open(fn).read())
Category:Implementations
Brainfuck Python interpreter (ChatGPT)

Here is a Brainfuck interpreter in Python. Edited from the Numberfuck interpreter which was coded by ChatGPT. Still is optimized for everything, including printing the full lyrics of the song Never Gonna Give You Up.
def interpret():
 code = input("Enter Brainfuck code: ")
 memory = [0] * 30000
 pointer = 0
 output_string = ""
 code_length = len(code)
 code_pointer = 0
 loop_stack = []
 commands = {
 '>': lambda: nonlocal_pointer('+'),
 '<': lambda: nonlocal_pointer('-'),
 '+': lambda: increment_memory(),
 '-': lambda: decrement_memory(),
 '.': lambda: output_to_string(),
 ',': lambda: take_input(),
 '[': lambda: start_loop(),
 ']': lambda: end_loop()
 }
 def nonlocal_pointer(op):
 nonlocal pointer
 if op == '+':
 pointer += 1
 else:
 pointer -= 1
 def increment_memory():
 nonlocal memory, pointer
 memory[pointer] = (memory[pointer] + 1) % 256
 def decrement_memory():
 nonlocal memory, pointer
 memory[pointer] = (memory[pointer] - 1) % 256
 def output_to_string():
 nonlocal memory, pointer, output_string
 output_string += chr(memory[pointer])
 def take_input():
 nonlocal memory, pointer
 user_input = input("Enter input (1 character): ")
 memory[pointer] = ord(user_input[0])
 def start_loop():
 nonlocal memory, pointer, code_pointer, loop_stack
 if memory[pointer] == 0:
 count = 1
 while count != 0 and code_pointer < code_length - 1:
 code_pointer += 1
 if code[code_pointer] == '[':
 count += 1
 elif code[code_pointer] == ']':
 count -= 1
 else:
 loop_stack.append(code_pointer)
 def end_loop():
 nonlocal code_pointer, loop_stack
 if memory[pointer] != 0:
 code_pointer = loop_stack[-1]
 else:
 loop_stack.pop()
 while code_pointer < code_length:
 command = code[code_pointer]
 if command in commands:
 commands[command]()
 code_pointer += 1
 print("Output:", output_string)
interpret()
Category:Implementations
Brainfuck Substitutor

Brainfuck Substitutor (also known as BF Substitutor or BFS) is an extension of Brainfuck that allows you to substitute parts of the code for variables.
There are two ways to write a program: In succinct mode, or in verbose mode.
By default, programs are read in succinct mode. To run in verbose mode, use the command line flag -v.
First, I will provide an explanation of how programs are read in verbose mode.
== Verbose Mode ==
Programs are written by assigning code to variables, like such:
a=+++++
Once BFS has read this line, all read code after that will have the character a substituted for +++++.
You can also assign variables using existing variables, like so:
a=+++++
b=aaaa
bb.
This will set a to +++++, b to aaaa, or equivalently ++++++++++++++++++++.
This will output the character (, with character code 40.
Due to the way this works, you can redefine characters in BF.
+=+++++
++++++++.
The above program will set the character + to be replaced with +++++. This will output (, with character code 40, as the are eight + symbols on the second line.
== Succinct Mode ==
In succinct mode, variables can only be assigned on the first line.
To define a variable, you remove the = sign:
a++++
Will set a to ++++
Remember the previous program I showed you in verbose mode, that looks like this:
a=+++++
b=aaaa
bb.
In succinct mode, you would rewrite it as this:
a+++++baaaa
bb.
Note that in this mode you may use = as a variable name unlike in verbose mode, but in this mode you cannot use any of +-<>[],. as variable names.
Also note that programs in succinct mode are required to have at least two lines of code.
== Hexadecimal Output ==
This is a command line argument that allows you to output in hexadecimal, for debugging purposes.
To output in lowercase hexadecimal, use -h. For uppercase hexadecimal, use -H. If, for some odd reason, you specify both -h and -H flags, -H will override.
== Running BFS ==
Currently there is only a Java interpreter, available here.
Usage: java -jar BrainfuckSubstitutor-1.0-SNAPSHOT.jar [args] <filename>
 Arguments:
 -v : Interpret in verbose mode
 -h : Output in hexadecimal
 -H : Output in hexadecimal (upppercase)
Arguments must always come before the filename. Arguments can be combined, like so:
java -jar BrainfuckSubstitutor-1.0-SNAPSHOT.jar -vh myfile
This will run the same as:
java -jar BrainfuckSubstitutor-1.0-SNAPSHOT.jar -v -h myfile
Category:Languages
Category:Brainfuck derivatives
Category:2017
Category:Turing complete
Category:Turing tarpits
Category:Implemented
Brainfuck but you get to jump back to first

brainfuck but you get to jump back to first is exactly what it sounds like, and many brainfuck experts have certainly thought of it before. maybe even wished it was real...
== commands ==
 +-<>[],. exactly as normal
 : go to start
== brainfuck equivalents ==
 beginning of program >
 > >+>
 < <-<
 ; <[<<]>
 [],.+- [],.+-
Category:Languages Category:Brainfuck derivatives Category:2024 Category:Unimplemented Category:Turing complete Category:Turing tarpits Category:Cell-based
Brainfuck code generation

This article presents known methods for representing brainfuck code in more readable forms and for generating brainfuck code from other languages.
Many schemes for representing and/or generating brainfuck code exist. They range from simple substitution macros to compilers from other languages. This page gathers a listing of such schemes together in one place.
==Macro systems==
* BrainClub
* eso_bfm
* The classic mandelbrot BF program was created using cpp as a macro compiler
* bfmacro
==Languages that compile to brainfuck==
* BFBASIC
* BFIL is an assembly like language designed to work as a compiler target that can further compile to brainfuck.
* C2BF
* Asm2bf
* FuckBrainfuck
* libbf contains a compiler from C to brainfuck
* Tbf
* EBF-compiler - An extension to BF where the compiler is written in itself (bootstrapped)
* bfcomp
* STBF
* BFFuck
* Headache (lang that compiles to brainfuck)
* FRAK
* Mastermind
==Other==
* Frans Faase's Brainfuck interpreter in Brainfuck was generated using this C program
* Using Artificial Intelligence to Write Self-Modifying/Improving Programs generates Brainfuck by using a genetic algorithm in C#
* ELVM Compiler Infrastructure is similar to LLVM but dedicated to Esoteric Languages; "frontends" are used to compile fron a source language into an intermediate representation, which is then used by "backends" to generate code for a target (esoteric) language. The only frontend available uses 8cc, a subset of C, while there are numeorus backeds, including one to compile to brainfuck.
* FuckBench is a development pipeline under Windows to generate and compile brainfuck code from several languages. It uses an emulator for the Motorola 6502 CPU written in FuckBrainfuck, so that any compiler that targets the 6502 CPU can be used to generate brainfuck code. Currently it supports generating code from FuckBrainfuck, 6502 assembly, C and Java, making available for the first time advanced programming constructs such as object-oriented programming, exceptions and multi-threading for generating brainfuck code.
Category:Brainfuck
Category:Compilers
Brainfuck compiler

== Brainfuck Compiler, Created by Polybagel ==
What is the brainfuck compiler?
The brainfuck compiler is a simple program that allows you to either copy paste, manually type, or open native brainfuck code and compile it into an exe file.
This does not add any additional commands, as it uses the vanilla commands. For those who need a quick refresher, here's a list of them.
Command	Description
> 	Move the pointer to the right
< 	Move the pointer to the left
+ 	Increment the memory cell at the pointer
- 	Decrement the memory cell at the pointer
. 	Output the character signified by the cell at the pointer
, 	Input a character and store it in the cell at the pointer
[ 	Jump past the matching ] if the cell at the pointer is 0
] 	Jump back to the matching [ if the cell at the pointer is nonzero
How does it work?
Well, its actually quite simple. The brainfuck compiler simply converts the brainfuck code into C code, and uses gcc to compile the exe file.
Additionally, the brainfuck compiler supports multi-line editing, there are no comments, as any characters that aren't commands are discarded, so any plain text is automatically a comment.
Where can I get the brainfuck compiler?
You can download it from this github link: https://github.com/Polybagel/Brainfuck-Compiler
Screenshots
Category:Implementations
Brainfuck derivatives

This page collects interesting Brainfuck derivatives which take the simple brainfuck language and change something to explore the space of languages near to brainfuck itself. It's aim is to let people flick over a collection of interesting brainfuck derivatives rather than having to dig through a very large list of derivatives. You are welcome to add more! There is a nicely tabulated page of Brainfuck_extensions.
== Boolfuck ==
Boolfuck is brainfuck with the cells only being booleans, in this language + and - are replaced with @ which flips the current cell. Despite this, it is still turing complete (a simple translation from it to brainfuck is possible by using 8 bitfuck cells to simulate one 8 bit brainfuck cell).
== Fuck ==
Fuck is a 0 dimensional version of brainfuck with only a single integer cell. The commands < and > are gone. Hello world is still possible but the language is not turing complete.
== Gridfuck ==
Gridfuck adds up ^ and down v operations to the language and lets you work with a grid of memory cells rather than a linear tape.
== Quantum brainfuck ==
Quantum brainfuck is an enhancement of brainfuck to work on qubits rather than classic integers.
== Harmful Brainfuck ==
Harmful Brainfuck is a brainfuck derivative that rejects the structured [] conditional loop operation and instead has a computed jump operation *. It is still under development.
== MNNBFSL ==
MNNBFSL is a stack based brainfuck derivative whose turing completeness isn't immediately obvious. It is possible to 'assemble' a higher level version of MNNBFSL that includes jumps down to it though, this shows it Turing complete.
== Reversible Brainfuck ==
Reversible Brainfuck tweaks a small number of the brainfuck operations so that no information is destroyed and the programs can be run forwards and backwards - despite this it is still Turing complete.
== /ˈæmbiːɛf/ ==
/ˈæmbiːɛf/ is a version of brainfuck that is operates so randomly that its computational class or ability to compute things with is not at all immediately obvious.
== Brainhype ==
Brainhype is a super-turing brainfuck that is able to tell if not only Turing machines halt, but even Brainhype programs too! It is believed to be possible to implement it in scheme-omega (although of course this cannot be done in this universe).
== MIBBLLII Isn't brainfuck But Looks Like It Is ==
MIBBLLII is actually a functional language based on combinatory logic that masquerades as brainfuck. It lets you write out combinators and function application in syntax that looks exactly like a brainfuck program.
== brainflop ==
brainflop is a Turing-complete, overly minimalist brainf**k derivative that has only 7 commands instead of 8 (it uses only one for control flow). It is extremely hard to program in.
== Motherf ==
Motherf adds variety of useful commands and principles like macros, stack, functions, convenient I/O, booleans and other types simulation.
category:Brainfuck derivatives
Brainfuck derivatives with nontrivial computational class proofs

This is a list of, as the name implies, brainfuck derivatives with nontrivial computational class proofs. It is for compiling brainfuck derivatives deemed "objectively interesting" by #esoteric by the standard of nontrivial computational class proofs. The plan was originally just interesting ones, but it was felt that that would not be objective enough, and that trivial languages like Ook! would eventually be added, thus degrading the page's integrity. 
This page is meant to compile not links, but full passages, so long as the description is short enough, such as to minimize the number of new pages.
Note that strict supersets of Brainfuck, along with Trivial Brainfuck Substitutions, are not applicable by nature.
== Permanent Brainfuck ==
The first BFDWaNTCCP is "Permanent Brainfuck", named by ais523 on #esoteric. Permanent Brainfuck is a brainfuck without a - (decrement) instruction, but that still has unbounded cells. This makes it so that, once a cell is incremented, it can never be zero again.
It should be noted that unbounded cells are important: each cell starts at 0 and can be successively incremented to any natural number, but never decremented. A bounded-cell implementation is trivially turing complete, because "-" can be replaced with "+" repeated wrappoint-1 times. Unbounded cells, on the other hand, being infinite, are undecrementable.
The most promising method for proving its computational class is Minsky machines.
:See Brainfuck minus -, which shows that ordinary brainfuck without '-' and no cell-wrapping is Turing-complete, and therefore shows that Permanent Brainfuck is Turing-complete too.
Category:Proofs
Brainfuck for humans

brainfuck 4 humans is a perfectly good esolang, with perfectly good syntax, but I think we can make it easier to read, y’know?
== Syntax ==
Brainfuck for humans has a similar syntax to brainfuck 4 humans, with the important addition of enumerated motions, for example: left 3; is equivalent to left;left;left; in brainfuck for humans, the syntax list is as follows:
(For this example we may assume m is the memory pointer and [m] is a dereference from m, otherwise C like syntax may be assumed)
# right x ; equiv to m += x
# left x ; equiv to m -= x
# zero ; [m] = 0
# add x ; equiv to [m] += x
# subtract x ; equiv to [m] -= x
# input ; equiv to bf(“,”)
# output ; equiv to bf(“.”)
# loop (s) ; while ([m]) { s }
# clear ; loop (subtract 1;);
# set x ; clear; add x;
# set ‘x’ ; set ord(x)
# string “x”; for(I=0; I<strlen(“x”); I++) { set “x”[I]; right 1; }
# read ; file=fopen(m, “r”); fread(m, 1, file_len, file);
# write ; file=fopen(m, “w”); fwrite(m+strlen(m)+1,1,strlen(m+strlen(m)+1),file);
# remark [ x ] ; /* x */
To put multiple statements on the same line use the keyword and or the
token &, a line should end with ..
== Hello World ==
The Hello World follows:
 zero and right 1.
 string "Hello World!" and add 10.
 right 1 zero.
 left 1 and loop (left 1) and right 1.
 write.
Which simply embeds a string with a newline at the end with a null terminator at the beginning and end. So that we can go to the beginning of the string by making sure we are inside of it, and then using
loop (left 1) and right 1. to go to the left until we reach the 
introductory NUL and then move forwards to the first character in the
string.
Category:Languages Category:Brainfuck derivatives Category:Turing complete Category:Cell-based Category:Unimplemented Category:2024
Brainfuck in Python

It is possible to emulate Brainfuck in Python.
Code:
##### Initialization. #####
array = [0 for i in range(32767)] # 32k RAM.
current_value = 0 # Pointer for array.
##### Actual code. #####
# Your commands here... #
To make the > command, do the following:
if current_value == 32767: # Wrap
 current_value = 0
else:
 current_value += 1 # Move right
To make the < command, do the following:
if current_value == 0: # Wrap
 current_value = 32767
else:
 current_value -= 1 # Move left
To make the + command, do the following:
if array[current_value] == 255: # Wrap
 array[current_value] = 0
else:
 array[current_value] += 1 # Increment
To make the - command, do the following:
if array[current_value] == 0: # Wrap
 array[current_value] = 255
else:
 array[current_value] -= 1 # Decrement
To make the , command, do the following:
array[current_value] = ord(input(' Enter exactly ONE character... >')) # Ask for input
To make the . command, do the following:
print(end=chr(array[current_value])) # Prints it out
To make the [ command, do the following:
while array[current_value] != 0: # Opens a loop
Also indent the items below.
To make the ] command, remove one layer of indentation.
Category:Implementations
Brainfuck is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

Brainfuck is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. (name should always be capitalized) or BINRATNOACFSFOOPCTSOTNOIAPWIVTTPICATA is an esolang invented by User:None1. It is TheLang but instead of the's, you write is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.'s.
==Examples==
===Output þ===
LZMA compressed and then Base-64 encoded:
/Td6WFoAAATm1rRGAgAhARYAAAB0L+Wj4NVZAOJdADScwAXiDJtL7WLG86Rq+6YtghF+HUTCvBl06VX7DnQwHBByDRyvrlb8vGUEOYSQLAArCLsxZM+Gmu6P3Pi34A7C653Th0KcVd+NJeQy/Imcc4aus+aX59UeJX5rNV4W0LlNw44V1PYgSyamIqEsUPY0mOdU7eQyos4DYn5C11hTReTz7Yqd/bzlUHD8Ijy2pYNhmK7z8Ewp5O8ck7iKBgfe6Y6nNY81MLKGyP5gtaL7b9yjfbo7yO5K8WrWSvDzFSgNFTT0cjQcqPYtfPq3KWbEIGJGuGI3FV1LlN2N1MYmAAAAAABkyh8pQkXSlQAB/gHaqgMAjFeGZ7HEZ/sCAAAAAARZWg==
==See also==
* Unary
* Dotfuck
* TheLang
Category:Languages
Category:2024
Category:Brainfuck derivatives
Category:Brainfuck equivalents
Brainfuck is not turing complete

This page is obviously a joke.
Today I will bring you a very difficult proof question. I'm willing to bet that even if all the deceased mathematicians and programming contributors around the globe were alive, they wouldn't necessarily have done it.
"Please prove that Brainfuck is not a Turing-complete programming language."
We all know three things:
 1. befunge-98 is turing complete
 2. brainfuck is 1d
 3. befunge-98 is 2d
∵befunge-98=F
brainfuck=B
F=2D
turing-complete=T
F=T
F=2D=T
2D=T
B=1D
1D≠2D
1D≠T
∴B≠T
Join me as we prove things that are wrong right, and destroy the world one peice at a time.
== If brainfuck were turing complete, 1=2 ==
=== Proof ===
B=T
F=T
F=2D
B=1D
2D=1D
Divide both sides of the equation by D at the same time to get: 1=2
Brainfuck with while 0 loops

This page is proof that brainfuck with unbounded tape and while 0 loops is Turing complete, which is proven by simulation of Cyclic Tag.
==Initialise data==
put +>> at the start of a program then initialise program with 0 being >+> and 1 being >>. After initialising data append >+<<[<<]>>[
==Simulating Cyclic Tag==
Replace every ; with +>>, 0 with +>[[>>]->+>+<<[<<]->+]<[+>-<]- and 1 with +>[[>>]->>+<<[<<]->+]<[+>-<]-. End program with ]. It also proves that it is Turing-complete with nesting depth of 3
==Explanation==
To simulate Cyclic Tag in this version of brainfuck we will use following layout:
 10 xy xy xy ... 1
x is 1 if bit is deleted and 0 otherwise. y is 1 if bit is 0 and 0 if bit is 1.
Category:Proofs
Brainfucker

Brainfucker is a derivative of brainfuck. Not wrapping, of course.
== Commands ==
 + add
 - subtract
 * square
 / square root
 . output as number
 , input as number
 [ jump to ] if 0
 ] jump to [ if non-0
 > move right
 < move left
 v move down
 ^ move up
== 123 (not hello world thats impossible) ==
 +++*++*++.
== See also==
* Brainfucker v1.1
Category:LanguagesCategory:2024
Brainfucker v1.1

== Commands ==
 + Increment
 - Decrement
 * Square
 / Square root
 . Output number
 , Input number
 O Output UTF-16
 I Input UTF-16
 [] Same as in brainfuck
 ^v Move between dimensions
 <> Move in a selected dimension
=== v1.2 ===
 <letter><commands>\n Define a function <letter> that does <commands>
 <letter> Call a function <letter>
=== v1.3 ===
 <number>(<commands>) Repeat <commands> multiple times
== Examples ==
=== 123 ===
 +++*++*++.
=== Hello world ===
 [Possible, but not provided]
=== XKCD Random Number ===
 ++*.
== See also ==
* Brainfucker
Category:Languages
Category:Turing complete
Category:Brainfuck derivatives
Category:2024
Brainfuckest

Brainfuckest is an esoteric programming "language" that represents brainfuck programs using all valid numbers, letters, and puncuation (excluding brackets).
==How it Works==
The following is a list of all the valid brainfuckest characters in order (including the space between M and the comma):
 0123456789qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM ,.?!;:
When running a brainfuckest program, it first converts the string you gave it into a number, it does this by finding the index of all the characters in the string into numbers corresponding to the list above.
for example:
 qwerty
becomes:
 10
 11
 12
 13
 14
 15
Then it runs through the list, and adds the result of the current index (starting from 0) multiplied by 69 to each item of the list
 10 = 10 + (69 * 0)
 80 = 11 + (69 * 1)
 150 = 12 + (69 * 2)
 220 = 13 + (69 * 3)
 290 = 14 + (69 * 4)
 360 = 15 + (69 * 5)
Next it adds them all together, in this case the result is 1110, and turns this into base 8 (In this case: 2126)
and turns each numberal into their corresponding brainfuck operation (in our case we get an error because the brainfuck code is invalid).
 +<+[
===Octal to Brainfuck===
 
brainfuck	Octal
> 	0
< 	1
+ 	2
- 	3
. 	4
, 	5
[ 	6
] 	7
==See Also==
* Brainfuck
==External Resources==
* Brainfuckest Interpreter made by User:Nurdle
Category:Languages 
Category:Brainfuck derivatives 
Category:Turing_tarpits 
Category:Turing_complete 
Category:Joke_languages 
Category:Implemented
Category:2022
Brainfuck²

Brainfuck2 is an esoteric programming language, a Trivial brainfuck substitution except this time actually funny. Every term in the language is a name of another brainfuck derivative. It was developed by a teenager from California as he sat on the toilet.
==Language==
Command 	Description
Ook! 	Move the pointer to the right
Alphuck 	Move the pointer to the left
Fuckfuck 	Increment the memory cell under the pointer
POGAACK 	Decrement the memory cell under the pointer. This one was especially unfunny. Not just a rip off of BF, but also a rip off of a rip off of BF.
Unibrain 	Output the character signified by the cell at the pointer
Wordfuck 	Input a character and store it in the cell at the pointer
Brainfuck²	Jump past the matching ZZZ if the cell under the pointer is 0
ZZZ 	Jump back to the matching Brainfuck² if the cell under the pointer is nonzero
Category:Languages
Category:Joke languages
Category:2017
Category:Brainfuck equivalents
Category:Turing complete
Category:Turing tarpits
Category:Low-level