I finally figured out how to write unreadable code in Python. See if you can figure out what the following code does:
@interact
def _(h=(20,(1,36,1))):
print (lambda f:f(0,f))(
lambda n,f:'%s\n%s'%(
('*'*(2*n+1)).join([' '*(h-n-1)]*2),
((n<h-1 and f(n+1,f)) or '')
)
)
Apart from the interact function overhead, the code can be compressed into one line. Motivated by a discussion about Maxima in SAGE.

No comments:
Post a Comment