Permufuck

From Esolang
Jump to navigation Jump to search
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 . Let denote the length of

1. Interpret as a bijective base-11 number. Set to be this number.
2. While is not empty, repeat steps 3-6.
3. Set to be .
4. Remove the th instruction in . Call the removed instruction .
5. Set to be .
6. Output the 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

+,[.,]