Created
January 9, 2015 00:52
-
-
Save eliasdorneles/8c0ddd5039ffce814a92 to your computer and use it in GitHub Desktop.
transpose in Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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