Skip to content

Instantly share code, notes, and snippets.

@Maltysen
Created June 7, 2015 18:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Maltysen/e8231c0a9b585e2a4941 to your computer and use it in GitHub Desktop.
Save Maltysen/e8231c0a9b585e2a4941 to your computer and use it in GitHub Desktop.
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