We are currently working on new rules for what content should and shouldn't be allowed on this website, and are looking for feedback! See Esolang:2026 topicality proposal to view and give feedback on the current draft.
Permufuck
- This is still a work in progress. It may be changed in the future.
- This article is not detailed enough and needs to be expanded. Please help us by adding some more information.
Permufuck, an esolang created by User:Pro465 in 2025, is a much harder variant of brainfuck. Each Permufuck program corresponds noninjectively to a brainfuck program, which is given by a pseudorandom permutation of the Permufuck program and its instructions. The rest of this article describes how the correspondence works.
The most important part of this is the function:
def f(n):
n+=n>>1
n^=n>>1
return n
which exibits pseudorandom behaviour when iterated.
Description
To start things off, first take the program and delete everything but the digits 1-8. Call this $ p $. Let $ \#p $ denote the length of $ p. $
1. Interpret $ p $ as a bijective base-11 number. Set $ n $ to be this number.
2. While $ p $ is not empty, repeat steps 3-6.
3. Set $ n $ to be $ f(n) $.
4. Remove the $ (n\operatorname {mod} \#p)+1 $th instruction in $ p $. Call the removed instruction $ r $.
5. Set $ n $ to be $ f^{r}(n) $.
6. Output the $ (n\operatorname {mod} 8)+1 $th item in +-,.<>[].
The output is the corresponding brainfuck program, which is then evaluated. If the resulting brainfuck program is not valid (i.e, it contains mismatched brackets,) the original Permufuck program isn't considered valid either.
Conversion program (Python)
Because English descriptions are bound to have ambiguity, here's a Python program to convert Permufuck programs to brainfuck:
def turn_into_int(p):
res=0
for i in p:
res=res*11+int(i)
return res
def f(n):
n+=n>>1
n^=n>>1
return n
def convert(prog):
p="".join(filter(lambda x: x in "12345678", prog))
n=turn_into_int(p)
res=""
while p:
n=f(n)
i=n%len(p)
r,p=int(p[i]),p[:i]+p[i+1:]
for _ in range(r): n=f(n)
res+="+-,.<>[]"[n%8]
return res
Examples
Cat program
(assuming EOF writes 0)
254115
discovered by User:Olus2000. It corresponds to
+,[.,]