In [1]:
# Get the imports out of the way
# We need byte storage, pycurl, and pickle
import pycurl
import pickle
from io import BytesIO

In [2]:
# Do the PycURL read as usual
url = "http://www.pythonchallenge.com/pc/def/banner.p"
rawData = BytesIO()

curlObj = pycurl.Curl()
curlObj.setopt(pycurl.URL, url)
curlObj.setopt(pycurl.WRITEDATA, rawData)
curlObj.perform()
curlObj.close()

In [6]:
# For some reason, calling pickle.load on the BytesIO object
# raises an EOFError. I wasn't able to figure out why exactly.
# Instead we have to call pickle.loads on the BytesIO's value
pickled = pickle.loads(rawData.getvalue())

# The un-pickled object is a list of lists of tuples.
# Each tuple has either a space or hash character and an integer
for p in pickled[:10]:
    print(p)


[(' ', 95)]
[(' ', 14), ('#', 5), (' ', 70), ('#', 5), (' ', 1)]
[(' ', 15), ('#', 4), (' ', 71), ('#', 4), (' ', 1)]
[(' ', 15), ('#', 4), (' ', 71), ('#', 4), (' ', 1)]
[(' ', 15), ('#', 4), (' ', 71), ('#', 4), (' ', 1)]
[(' ', 15), ('#', 4), (' ', 71), ('#', 4), (' ', 1)]
[(' ', 15), ('#', 4), (' ', 71), ('#', 4), (' ', 1)]
[(' ', 15), ('#', 4), (' ', 71), ('#', 4), (' ', 1)]
[(' ', 15), ('#', 4), (' ', 71), ('#', 4), (' ', 1)]
[(' ', 6), ('#', 3), (' ', 6), ('#', 4), (' ', 3), ('#', 3), (' ', 9), ('#', 3), (' ', 7), ('#', 5), (' ', 3), ('#', 3), (' ', 4), ('#', 5), (' ', 3), ('#', 3), (' ', 10), ('#', 3), (' ', 7), ('#', 4), (' ', 1)]

In [7]:
# After failing over and over to see a pattern, I gave in and Googled the
# solution. It turns out the object is a essentially a bitmap
# Each inner list represents a single line on the screen (where pickled[0] == top line).
# Each tuple describes what character to print, and how many of them.
for line in pickled:
    print(''.join(char * num for (char, num) in line))


                                                                                               
              #####                                                                      ##### 
               ####                                                                       #### 
               ####                                                                       #### 
               ####                                                                       #### 
               ####                                                                       #### 
               ####                                                                       #### 
               ####                                                                       #### 
               ####                                                                       #### 
      ###      ####   ###         ###       #####   ###    #####   ###          ###       #### 
   ###   ##    #### #######     ##  ###      #### #######   #### #######     ###  ###     #### 
  ###     ###  #####    ####   ###   ####    #####    ####  #####    ####   ###     ###   #### 
 ###           ####     ####   ###    ###    ####     ####  ####     ####  ###      ####  #### 
 ###           ####     ####          ###    ####     ####  ####     ####  ###       ###  #### 
####           ####     ####     ##   ###    ####     ####  ####     #### ####       ###  #### 
####           ####     ####   ##########    ####     ####  ####     #### ##############  #### 
####           ####     ####  ###    ####    ####     ####  ####     #### ####            #### 
####           ####     #### ####     ###    ####     ####  ####     #### ####            #### 
 ###           ####     #### ####     ###    ####     ####  ####     ####  ###            #### 
  ###      ##  ####     ####  ###    ####    ####     ####  ####     ####   ###      ##   #### 
   ###    ##   ####     ####   ###########   ####     ####  ####     ####    ###    ##    #### 
      ###     ######    #####    ##    #### ######    ###########    #####      ###      ######
                                                                                               

In [ ]: