Python Challenge level 5: “peak hell”
Level 5 is the first challenge specific to Python since it involves the pickle module in charge of Python object serialization.
Hint 1: pronounce it
Fact 1: there is a refference to a file named banner.p in the html source, so we’ll download it and see
Fact 2: once depickled, it looks like a run-length encoding
import urllib,pickle
url='http://www.pythonchallenge.com/pc/def/banner.p'
obj=pickle.load(urllib.urlopen(url))
for line in obj:
print ''.join(map(lambda pair: pair[0]*pair[1], line))
The output, in a pretty *nix banner command fashion, is:
channel
And that is Level 6.
You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
hi, how about the instruction set ? like I for what (lp0 for what.
[...] Python Challenge level 5: “peak hell” | UnixWars Python ? Pickle [...]
Thanks for this, I had no difficulty with the unpickling but just couldn’t figure out what the data meant.
I totally forgot that you can repeat strings with *, Python continues to impress me as I learn more.