Created
May 27, 2011 23:12
-
-
Save fathat/996372 to your computer and use it in GitHub Desktop.
Infinitely prints fractal triangles using only one root expression and no statements.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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() )() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For compatibility with both Python 2 and 3, on line 14 replace n/2 with n//2.