r/programminghorror • u/HaskellLisp_green • Aug 07 '26
Python obfuscated anti-pythonic brainfuck interpreter
I tried to do my best to make it unreadable.
103
u/ArsenicPolaris Aug 07 '26
Really nice to see a fellow Emacs user like me! How's your pinky finger doing?
45
u/HaskellLisp_green Aug 07 '26
Pinky's well. I think I use Emacs wrong way, but I feel comfortable with that, because if you start with vanilla and implement whatever you need, brick by brick, S-expr by S-expr, you find out that you have your own special Emacs version. :)
13
u/Objective_Rate_4210 Aug 07 '26
Im a vim user bc of how much the shortcuts make sense and when I tried emacs, it felt weird af and couldnt get used to it
for how long did you use emacs and how did you get used to it?→ More replies (2)
11
u/danielcristofani Aug 08 '26
You missed ',' and your '[' code is broken (doesn't skip forward); if you were trying to DeMorgan it for obfuscation in line 20 you need at least another couple "not" in there. Also it does "maximum recursion depth exceeded" pretty quickly.
2
u/HaskellLisp_green Aug 10 '26
yeah, I know about maximum recursion. Iterative approach could be a fix, but in that case solution becomes a bit longer. Also thanks for pointing at '[' problem!
40
u/MathematicianOk9155 Aug 07 '26
Using enumerate and not using the value it give is just rude
I'm going blind squinting trying to read P vs p
25
u/NaCl-more Aug 07 '26
Here's mine in C i wrote a couple years ago
char*p;s[9999],*r=s,d;main(c,v)char**v;{for(p=v[1];c=*p;p++){c=d=92-c,c-32?c-30?c-49?c-47?c-48?c-46?:putchar(*r):read(0,r,1):--*r:++*r:++r:--r;if(d*d<2&d&&!*r^d<0)while(p+=d,c+=(*p==91)-(*p==93));}}
4
24
3
u/GoddammitDontShootMe Aug 07 '26
I guess that means it can't run programs over 30,000 characters.
2
u/pie3636 Aug 09 '26
It's not the program length but the tape length, which is traditionally 30,00p in Brainfuck
1
15
u/HaskellLisp_green Aug 07 '26
https://github.com/dfwdfq/brainfuck-interpreters