Created
January 20, 2009 23:18
-
-
Save wacotaqo/49735 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| Python Challenge #5 | |
| =================== | |
| URL: http://www.pythonchallenge.com/pc/def/peak.html | |
| Peak hell.. what? | |
| Tried to search for python functions on google with peak or hell and happened to see a solution for the puzzle with the word "Pickle"... shucks. Wanted to ponder a little longer on that. | |
| Source code had a link to: http://www.pythonchallenge.com/pc/def/banner.p | |
| The data listed was unpickled as follows: | |
| import urllib | |
| url = r'http://www.pythonchallenge.com/pc/def/banner.p' | |
| data = urllib.urlopen(url).read() | |
| import pickle | |
| unpick = pickle.loads(data) | |
| unpick was a list of 23 lists each with one or more tuples with a character and an integer. | |
| E.g. One of the 23 rows looked like this: [(' ', 15), ('#', 4), (' ', 71), ('#', 4), (' ', 1)] | |
| Did some computations and chr/ord combinations with these but got nothing. | |
| Then looking from afar on a printout of the entire list in rows, I saw that the sum of the integers in each row was the same. I.e. 95. | |
| So i dawned on me that the image probably draws something if you print a list of characters for the length of each "integer". | |
| Hence, ('c', 3) would print ccc. | |
| Which led to... | |
| def strN(chr, cnt): | |
| reply = '' | |
| for i in range(0,cnt): reply += chr | |
| return reply | |
| output = [] | |
| for rowinput in unpick: | |
| rowoutput = '' | |
| for (ch, cnt) in rowinput: | |
| rowoutput += strN(ch, cnt) | |
| output.append(rowoutput) | |
| This gave the following output: | |
| ##### ##### | |
| #### #### | |
| #### #### | |
| #### #### | |
| #### #### | |
| #### #### | |
| #### #### | |
| #### #### | |
| ### #### ### ### ##### ### ##### ### ### #### | |
| ### ## #### ####### ## ### #### ####### #### ####### ### ### #### | |
| ### ### ##### #### ### #### ##### #### ##### #### ### ### #### | |
| ### #### #### ### ### #### #### #### #### ### #### #### | |
| ### #### #### ### #### #### #### #### ### ### #### | |
| #### #### #### ## ### #### #### #### #### #### ### #### | |
| #### #### #### ########## #### #### #### #### ############## #### | |
| #### #### #### ### #### #### #### #### #### #### #### | |
| #### #### #### #### ### #### #### #### #### #### #### | |
| ### #### #### #### ### #### #### #### #### ### #### | |
| ### ## #### #### ### #### #### #### #### #### ### ## #### | |
| ### ## #### #### ########### #### #### #### #### ### ## #### | |
| ### ###### ##### ## #### ###### ########### ##### ### ###### | |
| New Url: http://www.pythonchallenge.com/pc/def/channel.html |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment