the Python challange

Python get local varible, call

locals()

the Python challange

level 0 

2**38

1<<38

pow(2,38)

level 1

s="""
g fmnc wms bgblr rpylqjyrc gr zw fylb. rfyrq ufyr amknsrcpq ypc dmp. bmgle gr gl zw fylb gq glcddgagclr ylb rfyr'q ufw rfgq rcvr gq qm jmle. sqgle qrpgle.kyicrpylq() gq pcamkkclbcb. lmu ynnjw ml rfc spj.
"""
import string

mapping=string.maketrans('abcedfghijklmnopqrstuvwxyz','cedfghijklmnopqrstuvwxyzab')

print s.translate(mapping)

level 2

 

import re

data = """copy html source code highlighted"""

print "".join(re.findall("[A-Za-z]", data))

level 3

print "".join(re.findall("[^A-Z]+[A-Z]{3}([a-z])[A-Z]{3}[^A-Z]+", data))

level 4

import urllib

nothing = '12345'
while True:
    content = urllib.urlopen('http://pythonchallenge.com/pc/def/linkedlist.php?nothing=%(nothing)s' % locals()).read()
    try:
        nothing = str(int(content.split(' ')[-1]))
    except ValueError:
        if 'Divide' in content:
            nothing = str(int(nothing) / 2)
        else:
            break

print content
import requests
import re

next = "12345"

while next.isdigit():
    p = requests.get('http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing=%s' % next)
    if 'Divide' in p.content:
        next = str(int(next) / 2)
    else:
        message = "".join(re.findall('nothing is [0-9]*', p.content))
        next = message.lstrip('nothing is ')

print p.content

 

Leave a Reply

Your email address will not be published.

Notice: Undefined index: cookies in /var/www/html/wp-content/plugins/live-composer-page-builder/modules/tp-comments-form/module.php on line 1638