Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Golfed version to put in comments.
def f(s):
a,b=s.split('*');a,b=[reduce(lambda x,y:x+[1]*int(y)+[0],l,[0])for l in[a[::-1],b]];n=len(a)+len(b);l=[n*[' ']for i in range(n)]
for i,x in enumerate(a):
<tab>for j,y in enumerate(b):l[i+j][j-i+len(a)]=r' \/x'[x+2*y]
return '\n'.join(''.join(x[2:-1])for x in l[1:-2])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment