the Python challange
Python get local varible, call
locals()
2**38 1<<38 pow(2,38)
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)
import re data = """copy html source code highlighted""" print "".join(re.findall("[A-Za-z]", data))
print "".join(re.findall("[^A-Z]+[A-Z]{3}([a-z])[A-Z]{3}[^A-Z]+", data))
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