A compressed brainfuck interpreter for use in code golf.
- Each command in the program is converted to a respective octal digit.
- This octal is padded with enough of the
[
digit to represent a hex number with an even number of digits. The[
characters can just be removed later, as an[
will never be at the end of a program. - This hex is the new data and is read from or written to a file.
To encode a standard brainfuck file:
python brnfck.py encode infile.bf outfile.bk
The brnfck interpreter comes with a lot of different options to choose from, but to execute a file with the default settings invoke:
python brnfuck.py interpret file.bk
flag | meaning |
---|---|
[-i | --user-input] USER_INPUT |
the input for the program |
[-u | --upper] UPPER |
the upper bound for the value the cells can hold; default is unbounded |
[-l | --lower] LOWER |
the lower bound for the value the cells can hold; default is unbounded (negatively) |
[-d | --default] DEFAULT |
the default value that cells hold; 0 by default |
[-e | --eof] EOF |
the value to use when no more input can be taken |
[-w | --non-wrapping] |
disables the wrapping of data values in cells |
[-c | --non-encoded] |
interprets a non-encoded file |
Please let me know of any other programs / dialects that I can compare here
.[.,]
language | bytes output |
---|---|
brnfck | 2 |
CompressedFuck | 4 |
+[-->-[>>+>-----<<]<--<---]>-.>>>+.>>..+++[.>]<<<<.+++.------.<<-.>>>>+.
language | bytes output |
---|---|
brnfck | 40 |
CompressedFck | 42 |
>++++[<++++++++>-]>++++++++[>++++<-]>>++>>>+>>>+<<<<<<<<<<[-[->+<]>[-<+>>>.<<]>>>[[->++++++++[>++++<-]>.<<[->+<]+>[->++++++++++<<+>]>.[-]>]]+<<<[-[->+<]+>[-<+>>>-[->+<]++>[-<->]<<<]<<<<]++++++++++.+++.[-]<]+++++
language | bytes output |
---|---|
brnfck | 79 |
CompressedFck | 108 |
Please feel free to contribute to this project (create issues/fixes etc.) especially if you can compress the files more.