Brainfuq brings together classical Brainfuck and its quantum counterpart. Modify both a classical tape of bits using brainfuck operations and a quantum tape of qubits using operations for quantum circuits.
Classical Brainfuck operations
| Operation | Description |
|---|---|
> |
Increment pointer |
< |
Decrement pointer |
+ |
Increment byte at pointer |
- |
Decrement byte at pointer |
. |
Print byte at pointer |
, |
Write user input to byte at pointer |
[ |
Jump past matching ] if byte at pointer is 0 |
] |
Jump back to matching [ if byte at pointer is not 0 |
Quantum Brainfuck operations
| Operation | Description |
|---|---|
} |
Increment pointer |
{ |
Decrement pointer |
* |
Apply |
~ |
Apply |
; |
Apply |
: |
Measure qubit at pointer and print outcome |
# |
Control next gate on the qubit at pointer |
? |
Apply next gate only if last measurement was 1 |
Read this report for more details.
-
Interpret a Brainfuq program using a simulator with support for arbitrary quantum states
brainfuq simulate "~,-[#}*-]" -v -
Translate a Brainfuq program into a Qiskit circuit
brainfuq to-qiskit -o ghz.qpy "~,-[#}*{:}-]:" -
Generate a Brainfuq program from a Qiskit circuit
brainfuq from-qiskit ghz.qpy
Requirement:
-
python$\ge 3.14$
Setup:
Create and activate venv:
python -m venv .venv && source .venv/bin/activate
Install dependencies and CLI:
pip install -e .
Running:
Print CLI help:
brainfuq -h
For examples of how to use the interpreter with Python code, see the examples directory.
By Paul and Daniel