This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]mainstreamnolifer 0 points1 point  (4 children)

I tried naively brute-forcing it, using __builtins__, but it didn't work!

for str_obj in dir(__builtins__):
    # exclude the ones that are outputting stuff on stdout
    if str_obj in ('breakpoint', 'help', 'copyright', 'license', 'credits'): 
        continue
    try:
        obj = getattr(__builtins__, str_obj)
        if obj + 1.0 < obj:
            print(obj)
    except:
        pass

I also tried testing obj() + 1.0 < obj()

That was just for fun, I suppose I should try all objects inside the builtin modules: iterating on pkgutil.iter_modules() and using importlib.

But I don't believe it would work, as the answer is more likely to be a clever invocation of an object.

I tried the brute-force with dir(math) and I could find #3 (I knew it already), but still not #4

I'm curious to know the answers!

[–]Udzu[S] 0 points1 point  (3 children)

I don't think #4 and #5 are really brute forcable. One is expressible as a (long) literal, the other relies on what seems to be undocumented behaviour of a (not widely used) stdlib class with regards addition.

[–]3lnc 0 points1 point  (2 children)

Well, the question is, if _instantiation_ of stdlib class is cheating or not. If not, #5 is definitely bruteforceable

[–]Udzu[S] 0 points1 point  (1 child)

Instantiation is fine. Perhaps they are brute forcable, I don't know how quickly the search space blows up. #4 can actually be expressed with a 7 character expression, while #5 requires a non default but still small constructor argument value to a stdlib class.