Yikes, how deep can you go on writing a #Python expression with more and more limiting rules:
oskaerik.github.io/theevalgame

Spoiler for rule 10 

@nedbat finished!

Spoilers for rule 10:

No idea if this was how I was "supposed" to solve it, but I just bypassed the restriction by shallow-copying the builtins dict like this:

(__builtins__ := {k, v for k, v in __builtins__.items()}) and ... rest of expression ...

Looks like the puzzle had a tripwire on the original object's __getattr__ or something, which is why copying didn't trigger it. The rest of the expression stayed the same because of python's lookup rules.

Spoiler for rule 10 

@christmastree Hmm, you might have found a loophole!

Spoiler for rule 10 

@nedbat I can only think of two other ways around this.

1. (probably also considered a loophole) putting the whole expression in a lambda, and assigning locals() to a copy of builtins. This doesn't work outside the lambda because it needs to go through __builtins__ to find locals() in the first place!

2. Something like this which I did not feel like doing: netsec.expert/posts/breaking-p 😅

Follow

Spoiler for rule 10 

@christmastree @nedbat This is what I came up with (which basically uses your #2): gist.github.com/pganssle/d8496

Sign in to participate in the conversation
Qoto Mastodon

QOTO: Question Others to Teach Ourselves
An inclusive, Academic Freedom, instance
All cultures welcome.
Hate speech and harassment strictly forbidden.