Skip to content

Instantly share code, notes, and snippets.

@rbonvall
Created February 2, 2016 20:59
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 rbonvall/d413adb74478bd41bc83 to your computer and use it in GitHub Desktop.
Save rbonvall/d413adb74478bd41bc83 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
from numpy import *
#r = raw_input()
r = 'Programming Puzzles & Code Golf'
s = sign(diff(map(ord, r[0] + r)))
c = cumsum(s)
p = 2 * (max(c) - c) + 1
w = max(p) + 1
lr = [l .rjust(i).ljust(w) for i, l in zip(p, r)]
sr = ['-/\\'[j].rjust(i).ljust(w) for i, j in zip(p+s, s)]
rv = ravel(vstack([sr, lr]).T)[1:]
m = array([''.join(list(row)) for row in rv]).T
m = array(map(''.join, map(list, rv))).T
ar = array([list(row) for pair in zip(sr, lr) for row in pair][1:]).T
for row in ar:
print ''.join(row)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment