-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathproject-euler-offline.py
More file actions
44 lines (38 loc) · 1.12 KB
/
Copy pathproject-euler-offline.py
File metadata and controls
44 lines (38 loc) · 1.12 KB
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
#!/usr/bin/env python
'''
project-euler-offline.py
Christopher Su
Checks solutions to Project Euler problems offline.
'''
import os
import json
from pyDes import *
def loadJSON(jsonStr):
try:
data = json.loads(jsonStr)
except ValueError:
logging.exception("Error parsing %s." % json_file)
sys.exit(1)
return data
def main():
dir = os.path.dirname(__file__)
txtFile = open(os.path.join(dir, "solutions-encrypted"), "rb")
txtStr = txtFile.read()
txtFile.close()
plain_text = triple_des('03b5660c7c16a07b').decrypt(txtStr, padmode=2)
solutions = loadJSON(plain_text)
current = input("What problem are you currently working on? ")
while True:
proposed = input("\nEnter solution: ")
if proposed == "exit":
break
elif proposed == solutions[current]:
print("Correct!")
current = input("\nWhat problem are you working on? ")
if current == "exit":
break
else:
print("Sorry, that is incorrect.")
if __name__ == "__main__":
dir = os.path.dirname(__file__)
main()