Python Challenge level 17: “eat?”

Level 17 is cookie related, so urllib usage is needed once again.

Hint 1: cookies in the photo. Unambiguous!
Hint 2: there’s a thumbnail of the image from level 4

So, we’ll have to investiagate the http headers. Interestingly, we find out something in level 4.

Fact 1:info=you+should+have+followed+busynothing…;” is a cookie set by level 4.
Fact 2: busynothing is another linkedlist, and has a chinging cookie!
Fact 3: once obtained every piece, the info seems to be a quote_plus string from a BZ2 chunk of data

The code for this part of the riddle would be:

import urllib,re,bz2
url='http://www.pythonchallenge.com/pc/def/linkedlist.php?busynothing='
seed="12345"
info=''
while True:
    req=urllib.urlopen(url+seed)
    text=req.read()
    seed=''.join(re.findall(r"busynothing is (\d+)",text))
    cookies=req.info().getheaders('Set-Cookie')[0]
    byte=cookies.split(';')[0].split('=')[1]
    info+=byte
    try :
        int(seed)
        print "   Info:",byte,"t   Next:",seed
    except :
        print "   Info:",byte,"t   Last:",text
        break
print "info:",bz2.decompress(urllib.unquote_plus(info))

is it the 26th already? call his father and inform him that “the flowers are on their way”. he’ll understand.

This one is intricate. Lets use level 13′s phonebook to find Mozart’s father’s phone. His name was Leopold by the way:

violin

From there to here, and stuck again. The only hint now is the page title: “it’s me. what do you want?”
Now it’s time to give him the message. After some trial and error and no RPC errors seen, setting a cookie with the message will show itself as the way to go.

from urllib2 import Request,urlopen
from urllib import quote_plus
info='the flowers are on their way'
url='http://www.pythonchallenge.com/pc/stuff/violin.php'
req = Request(url, headers={'Cookie': 'info=' + quote_plus(info)})
print urlopen(req).read()

oh well, don’t you dare to forget the balloons

Balloons! Finally Level 18.

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.

6 Comments »

 
  • Gamut says:

    In the line
    seed=”.join(re.findall(r”busynothing is (d+)”,text))
    the d+ should read \d+

  • For some reason the slashes were deleted from this and several other code snippets. Thanks for noticing! :)

  • hi! Thats a wonderful edu blog. I think edu stands for quality (=

  • cin takvimi says:

    I am not very wonderful with English but I get hold this really easygoing to interpret .

  • drm / Gerard says:

    After some hours, I am pretty sure the challenge is broken :( My own solution should be correct and after trying the one here I am convinced. Directly after 12345, the next info cookie sent back to me is ‘deleted’, which can’t be right. Very sad, because I was having fun, and this just cost me some hours looking for something that doesn’t seem to be there at all, pissing me off really :( :(

    Why rant on your blog? Maybe it will help the next poor sod, because registering at the pythonchallenge forum seems disabled, and this is probably the best ranking page when looking for solutions.

  • Tal says:

    It doesn’t seem to work anymore. No cookies after the first page…

 

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>