Last active
December 28, 2015 18:19
-
-
Save zemlanin/7542237 to your computer and use it in GitHub Desktop.
Project Euler 59
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import itertools, string, operator, requests | |
cypher = map(int, requests.get('https://projecteuler.net/project/cipher1.txt').text.split(',')) | |
for pwd in itertools.product(string.ascii_lowercase, repeat=3): | |
phrase = ''.join(itertools.imap(lambda x,y: chr(operator.xor(x, y)), cypher, itertools.cycle(map(ord, pwd)))) | |
if 'the' in phrase.lower() and 'and' in phrase.lower() and ' ' in phrase: | |
print phrase, '\n|\n+->\t', ''.join(pwd), '\n' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment