Dec 17 2011

Lambda!

Made this goofing around to see if I could compress an entire python program into a single expression. Who said Python Lambda’s aren’t powerful?!

(lambda:
    not globals().__setitem__('sys', __import__('sys'))
    and not globals().__setitem__('this', sys.modules[globals()['__name__']])
    and not globals().__setitem__('time', __import__('time'))
    and
    #program
    [setattr(this, k, v) for k,v in {
            'set_color': (lambda c: w(['*', ' '][c])),
            'abs': (lambda t: (t + (t >> 31)) ^ (t >> 31)),
            'w': sys.stdout.write,
            'smash': (lambda t: -((t * -1) >> 31)),
            'color': (lambda n,k: set_color(smash (k & (n - k)))),
            'col': (lambda n, k: k <= n and not color(n,k) and col(n,k + 1)),
            'row': (lambda n: not w(' ' * (40-abs(n/2)))
                              and (col(abs(n), 0) or True)
                              and not w("\n")
                              and (abs(n) < 63 or n < 0)
                              and not time.sleep(0.05)
                              and row(n+1)),
            'triangle': lambda: row(-60) or True and triangle()
        }.items() ] and triangle() )()

 


Leave a Reply

Your email address will not be published. Required fields are marked *