New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Brainfuck interpreter #470
Conversation
re-added test_tap_code() removed tap_code test by mistake, should be fixed.
@all-contributors please add @mav8557 for code |
I've put up a pull request to add @mav8557! 馃帀 |
This is some great code, excellent self-documenting code 馃憤 |
Hey we're changing from MIT to GPLv3 because some of our projects are licensed with that, do you approve? If you do not approve we will be forced to delete your code and rewrite it 馃槩 By approving of this change, you are agreeing to re-license the code you wrote under GPLv3. |
That's totally fine. Thanks! |
Thank you!!! |
Hello! Great project idea everyone 馃憤 and thanks for opening to contributors.
This PR adds a Brainfuck decoder. Brainfuck as a language does support user input (a "key" in this case), but the keyspace in this case is practically infinite. For that reason I'd argue a Brainfuck decoder is appropriate, especially for those CTF problems that simply convert strings to Brainfuck programs.
As a result, this decoder is a trimmed implementation of a full Brainfuck interpreter.
A program that can be "decoded" with this is one that:
(excluding ",") and whitespace.
The last requirement isn't actually a requirement going forward, as some programs might have comments or other text inside of them that can usually be safely ignored. Right now the code does enforce this and return None if there are comments or anything outside of the Brainfuck operators and whitespace, as well as if any of the other requirements are violated.
As requested in #353 the decoder will timeout eventually, at 60 seconds by default. This seemed high to me but if it's alright with you then it's okay.
The Brainfuck specification asks for 30000 memory cells by default, but this seemed excessive for programs that are often not that long. Instead the code starts with 100 cells and appends on any as needed. This can also be changed and is definitely something that I chose arbitrarily as a speed trade-off, so feel free to course correct me on that and we can choose to stick to the spec or something else instead.
Looking to hear what you all think. Thanks for the help with getting started and for maintaining the project!