Skip to content

Instantly share code, notes, and snippets.

@eliasdorneles
Created January 9, 2015 00:52
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 eliasdorneles/8c0ddd5039ffce814a92 to your computer and use it in GitHub Desktop.
Save eliasdorneles/8c0ddd5039ffce814a92 to your computer and use it in GitHub Desktop.
transpose in Python
import sys
STRING_COUNT = 6
def tab_column(fret, string):
return (['---'] * (string - 1) +
[fret.ljust(3, '-')] +
['---'] * (STRING_COUNT - string))
def tab_line(line):
(string, fret) = line.split()
return tab_column(fret, int(string))
for l in zip(*[tab_line(line) for line in sys.stdin]):
print(''.join(l))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment