Skip to content

Instantly share code, notes, and snippets.

@miketaylr miketaylr/one.py
Last active Aug 14, 2018

Embed
What would you like to do?
#!/usr/bin/python3
import webbrowser
# starting from http://www.pythonchallenge.com/pc/def/0.html
new_path = 2 ** 38
new_url = "http://www.pythonchallenge.com/pc/def/{}.html".format(new_path)
webbrowser.open(new_url)
# takes me to http://www.pythonchallenge.com/pc/def/map.html
# SEEMS LIKE IT WORKED
#!/usr/bin/python3
import string
import webbrowser
scrambled = """
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.
"""
# k->m
# o->q
# e->g
# mapping from N to N+2 in the alphabet.
start = string.ascii_lowercase
finish = string.ascii_lowercase[2:] + string.ascii_lowercase[:2]
table = str.maketrans(start, finish)
print(scrambled.translate(table))
#prints i hope you didnt translate it by hand. thats what computers are for. doing it in by hand is inefficient and that's why this text is so long. using string.maketrans() is recommended. now apply on the url.
url = "map"
new_url = "http://www.pythonchallenge.com/pc/def/{}.html".format(url.translate(table))
webbrowser.open(new_url)
# wowowow http://www.pythonchallenge.com/pc/def/ocr.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.