Challenge 5

Well this is not an easy one.

The unpickling is as easy as it should:

import pickle

f = open(”banner.p”, “r”)
x = pickle.load(f)
But after that I was lost. x is a list of lists, with 23 items, each item are constructed with one or more tuples, each tuple has two elements: one ” ” or “#”, and one number. What should I do with this?

I re-read the pickle documents several times and there looks no other thing I can do.

The HTML said “pickle banner.p”. Should I pickle it instead of unpickle it? I pickled x with different protocols, but protocol 1 and 2 produced binary output, that I can’t understand.

The first and last elements of x are all [” “, 95]. So these should be the same letter. But 95 in ASCII is “_”. What’s that?

The file name is “banner.p”. Is this related? There’s no banner in the picture. Wait… The pic!

I looked through the hex of the JPG but found the number in x doesn’t mean a position as I thought: there are too many small numbers ([0-9]).

a

for i in x:
print len(i)

doesn’t help. The numbers are odd.

then

for i in x:
print i

And i was caught by the first several lines:

[(’ ‘, 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)]

There looks there are some patern in it… Yes, the number in each line adds up the same! It’s 95! So the ” ” and “#” must be standing for something, like 0 and 1!… Or is this a bitmap picture?

f2 = open("out", "w")

for i in x:
for j in i:
f2.write(j[0]*j[1])
f2.write(”\n”)

f2.close()
And I got in the file out: channel ! The Challenge 6 is at http://www.pythonchallenge.com/pc/def/channel.html !

Finially I understand what the “banner” mean, the out put in file out looks like the output of command banner :)

Finially I got this. Now challenge 6:

The title is “now there are pairs”. There’s no hint. Again there’s some hint in the HTML source: zip. I know there’s a gzip module and a zipfile module. But what are they expecting me to do? Zip the picture? Or the HTML file?

Well I’ve spend too much time on this today so let’s wait for tomorrow. Things are getting harder, and more interesting :)

Tags: , ,

Post a Comment

You could use <code type="name"> to get your code colorized

Your email is never published nor shared. Required fields are marked *

Close
E-mail It