Exemplo n.º 1
0
#!/usr/bin/env python
#http://www.pythonchallenge.com/pc/def/peak.html

from pc import url

import cPickle as pickle

blob = pickle.loads(open('data/banner.p').read())

# the blob is a list of lists of pairs. the first item is a # or a space
# the second is an integer. because of the name banner, this is going
# to be printed

for line in blob:
    print ''.join(pair[0]*pair[1] for pair in line)

# the output looks like the word CHANNEL

# print the next level URL
print url.format('channel')
Exemplo n.º 2
0
#!/usr/bin/env python
#{ challenge url }

from pc import url

# print the next level URL
print url.format(ans)
Exemplo n.º 3
0
#!/usr/bin/env python
#http://www.pythonchallenge.com/pc/def/map.html

from pc import url

import string

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."

# this isn't the completely correct translation table, but it works
trans = string.maketrans(string.lowercase, ''.join([chr(ord(c)+2) for c in string.lowercase]))

print s.translate(trans)

print url.format('map'.translate(trans))
Exemplo n.º 4
0
from pc import url

import re, urllib2


def step(n):
    u = 'http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing={0}'
    out = urllib2.urlopen(u.format(n)).read()
    return out


# after a bunch of steps you get to 92118 and it tells you to divide by
# two and keep going
n = str(92118 / 2)

rx = re.compile(r'the next nothing is (\d+)')

try:
    while True:
        out = step(n)
        print 'out:', out
        n = rx.search(out).groups()[0]
        print 'next:', n

except KeyboardInterrupt:
    pass

# print the next level URL
print url.format('peak')
Exemplo n.º 5
0
#!/usr/bin/env python
#http://www.pythonchallenge.com/pc/def/0.html

from pc import url

print url.format(2**38)
Exemplo n.º 6
0
#!/usr/bin/env python
#http://www.pythonchallenge.com/pc/def/linkedlist.php

from pc import url

import re, urllib2

def step(n):
    u = 'http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing={0}'
    out = urllib2.urlopen(u.format(n)).read()
    return out

# after a bunch of steps you get to 92118 and it tells you to divide by
# two and keep going
n = str(92118 / 2)

rx = re.compile(r'the next nothing is (\d+)')

try:
    while True:
        out = step(n)
        print 'out:', out
        n = rx.search(out).groups()[0]
        print 'next:', n

except KeyboardInterrupt:
    pass

# print the next level URL
print url.format('peak')
Exemplo n.º 7
0
#!/usr/bin/env python
#http://www.pythonchallenge.com/pc/def/map.html

from pc import url

import string

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."

# this isn't the completely correct translation table, but it works
trans = string.maketrans(string.lowercase,
                         ''.join([chr(ord(c) + 2) for c in string.lowercase]))

print s.translate(trans)

print url.format('map'.translate(trans))
Exemplo n.º 8
0
#!/usr/bin/env python
#http://www.pythonchallenge.com/pc/def/peak.html

from pc import url

import cPickle as pickle

blob = pickle.loads(open('data/banner.p').read())

# the blob is a list of lists of pairs. the first item is a # or a space
# the second is an integer. because of the name banner, this is going
# to be printed

for line in blob:
    print ''.join(pair[0] * pair[1] for pair in line)

# the output looks like the word CHANNEL

# print the next level URL
print url.format('channel')