-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchallenge05.py
More file actions
30 lines (26 loc) · 985 Bytes
/
challenge05.py
File metadata and controls
30 lines (26 loc) · 985 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/env python
# encoding: utf-8
"""
challenge05.py
http://www.pythonchallenge.com/pc/def/peak.html
pickle:
http://www.pythonchallenge.com/pc/def/banner.p
Created by whimsy on 2010-08-31.
Completed on 2010-11-09.
Copyright (c) 2010 Will Crawford. All rights reserved.
"""
import sys
import os
import cPickle as pickle
def main():
print "This program expects banner.p in the same directory."
print "It should be named challenge05.p"
print "The next challenge word is..."
the_pickle = pickle.load( open("challenge05.p"))
for element in the_pickle: # Traverse the first set of lists
for subelement in element: # Traverse the lists in the lists
for i in range(subelement[1]): # The second tuple element contains repetition information
sys.stdout.write(str(subelement[0])); # The first tuple element contains the character to be repeated.
sys.stdout.write('\n') # Each element in the_pickle is a separate banner line.
return 0
if __name__ == '__main__': main()