Skip to content

Instantly share code, notes, and snippets.

@zemlanin
Last active December 28, 2015 18:19
Show Gist options
  • Save zemlanin/7542237 to your computer and use it in GitHub Desktop.
Save zemlanin/7542237 to your computer and use it in GitHub Desktop.
Project Euler 59
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