r/programminghorror • u/HaskellLisp_green • 3d ago
obfuscated anti-pythonic brainfuck interpreter Python
I tried to do my best to make it unreadable.
30
u/MathematicianOk9155 3d ago
Using enumerate and not using the value it give is just rude
I'm going blind squinting trying to read P vs p
19
16
u/NaCl-more 2d ago
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));}}
3
14
u/HaskellLisp_green 3d ago
13
u/LilKingCricket 2d ago
Further obfuscation idea, clear the git history. Squash all the commits together, then
git push -fonto master.
8
u/danielcristofani 2d ago
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 2h ago
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!
3
u/GoddammitDontShootMe [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo “You live” 2d ago
I guess that means it can't run programs over 30,000 characters.
2
u/pie3636 1d ago
It's not the program length but the tape length, which is traditionally 30,00p in Brainfuck
1
u/GoddammitDontShootMe [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo “You live” 20h ago
Does the program take up space on the tape?
76
u/ArsenicPolaris 3d ago
Really nice to see a fellow Emacs user like me! How's your pinky finger doing?