Created
January 9, 2013 22:23
-
-
Save 6r1d/4497552 to your computer and use it in GitHub Desktop.
SnakeText: new version of an old joke
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
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
import codecs | |
# Open file and load lines | |
with codecs.open('msg.txt', encoding='utf8') as f: | |
lines = [line.strip() for line in f] | |
# Counting lines | |
linesCount = len(lines) | |
# Max line length | |
maxlen = max([len(line) for line in lines]) | |
# Make symbol lists, similar by length from lines | |
lines = [list(line + ' ' * (maxlen - len(line))) for line in lines] | |
# Rotate odd lines | |
lines = [(lines[line_num][::-1] if line_num % 2 | |
!= 0 else lines[line_num]) for line_num in range(len(lines))] | |
# Show the stuff | |
print u'\n'.join([''.join([lines[i][j] for i in range(linesCount)]) | |
for j in range(maxlen)]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment