Python 2, Cracked
This is the second iteration of an answer that has been cracked once by @HyperNuetrino using a method I had not expected. I've now patched it so hopefully the only solutions left will have to abide by the restrictions I intended.
Implements addition as a named function
import sys
c="".join(open(__file__).read().split('\n')[4:])
if set(c)-set(' &)(,.:[]a`cdfijmonrt~')or"import"in c:sys.setrecursionlimit(1)
sys.modules['sys'],sys.modules['os']=None,None;del sys;f=lambda\
What does this do?
For the purposes of helping you out a bit I'll explain what this does. This code opens the source file and checks if the remainder of the code fits the following criteria:
- Does not contain the string
import
- Is made solely of the characters
&)(,.:[]a`cdfijmonrt~
If it fails either criterion the recursion limit is set to 1
meaning that any code you write will hit the recursion limit.
There are no tricks here, I have written a solution that uses only these characters and no imports, I'm not doing anything subversive, but I will say that I think this will be pretty hard to crack.
To save you some time here is a short list of useful things you cannot do with this restriction
+
well duh,eval
/exec
Wasn't going to let you get away with thatNumbers, They might be more useful than you think
String literals
len
=
, No assigning variables>
,<
,==
. . . I have left you with no comparisons*
,-
,/
,%
,^
,|
,>>
,<<
The only operators available are~
and&
__foo__
, None of those fancy double underscore methods are allowed.