Skip to content

Instantly share code, notes, and snippets.

@miketaylr
Last active August 14, 2018 21:45
Show Gist options
  • Save miketaylr/45910e352815ef195e4c65c0952647a5 to your computer and use it in GitHub Desktop.
Save miketaylr/45910e352815ef195e4c65c0952647a5 to your computer and use it in GitHub Desktop.
#!/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