Ad
  • Custom User Avatar

    HERES MINE:

    import sys

    class Cursed(type):
    def new(cls, name, bases, attrs):
    sys.stdout.write("".join(map(chr, [104, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100, 10])))
    return super().new(cls, name, bases, attrs)

    class _(import("builtins").object, metaclass=Cursed):
    pass

    def cursed_decorator(f):
    exec("print('hello world')")
    return lambda: None

    @cursed_decorator
    def totally_normal_function():
    print("hello world")

    (eval("import('builtins').exec"))("print('hello world')")

    import types
    bc = compile("print('hello world')", "", "exec")
    types.FunctionType(bc, {}).call()

  • Custom User Avatar

    Here is my cursed code to print "hello world":

    def hello_world():
        import functools
        import operator
        global the_most_peculiar_global_variable
        def a_function_that_does_almost_nothing():
            def another_incredibly_boring_function(input_parameter_x):
                return input_parameter_x
            return another_incredibly_boring_function
        the_most_peculiar_global_variable = a_function_that_does_almost_nothing()
        a_list_of_random_things = list()
        for a_totally_arbitrary_number in (0x68, 0x65, 0x6C, 0x6C, 0x6F, 0x20, 0x77, 0x6F, 0x72, 0x6C, 0x64):
            exec(f"a_list_of_random_things.append(chr(a_totally_arbitrary_number))")
        def a_function_that_combines_things_together(a_list_of_items):
            def a_sub_function_that_adds_items(item_a, item_b):
                return item_a + item_b
            a_resulting_amalgamation = functools.reduce(a_sub_function_that_adds_items, a_list_of_items, "")
            return a_resulting_amalgamation
        result = the_most_peculiar_global_variable((lambda an_input_list: a_function_that_combines_things_together(an_input_list))(a_list_of_random_things))
        return result
    

    Enjoy ! :)

  • Custom User Avatar

    Nearly. Right idea though

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    Hi.
    I'm surprised by these two test cases that seem to contradict each other:
    fn x => 0 must raise an error according to the button test,
    fn one => 1 must be a valid function with no arguments and always return 1 according to the attempt.

    In my opinion the first test case means 'a function must have a name' but in that case x could be considered to be the name of a function..

    Should the test case be modified?
    How did you managed this?