-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProblem 59.py
46 lines (38 loc) · 1.22 KB
/
Problem 59.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# -*- coding: utf-8 -*-
"""
Created on Sat Dec 22 11:04:53 2012
@author: Lucas
"""
extdatafile = open('data.txt', 'r')
rawextdata = str(extdatafile.readline())
extdata = ([])
for a in rawextdata.split(','):
extdata.append(int(a.strip(' ').strip('\n')))
alphabet = (['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'])
possiblekeys = ([])
for letter1 in alphabet:
for letter2 in alphabet:
for letter3 in alphabet:
current = ([])
current.append(ord(letter1))
current.append(ord(letter2))
current.append(ord(letter3))
possiblekeys.append(current)
for key0_ in possiblekeys:
for i in xrange(3,1205):
key0_.append(key0_[i-3])
for m in xrange(0,len(possiblekeys)):
xoredlist = ([])
for n in xrange(0,1201):
xoredlist.append(chr(possiblekeys[m][n] ^ extdata[n]))
xoredstr = ''
for char_ in xoredlist:
xoredstr += str(char_)
if '{' not in xoredstr and '}' not in xoredstr:
if 'beginning' in xoredstr:
print xoredstr
break
answer = 0
for char999_ in xoredstr:
answer += ord(char999_)
print answer