-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgpt3_solution.py
More file actions
23 lines (20 loc) · 803 Bytes
/
Copy pathgpt3_solution.py
File metadata and controls
23 lines (20 loc) · 803 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import json
import time
# START - CODE GENERATED BY gpt3
def solution():
with open('p059_cipher.txt', 'r') as f:
cipher = list(map(int, f.read().split(',')))
for i in range(97, 123):
for j in range(97, 123):
for k in range(97, 123):
key = [i, j, k]
message = [cipher[n] ^ key[n % 3] for n in range(len(cipher))]
text = ''.join([chr(m) for m in message])
if ' the ' in text.lower():
return sum(message)
# END - CODE GENERATED BY gpt3
cpu_s, wall_s = time.process_time(), time.time()
result = solution()
cpu_e, wall_e = time.process_time(), time.time()
cpu_time, wall_time = cpu_e - cpu_s, wall_e - wall_s
print(json.dumps({"solution": result, "cpu": cpu_time, "wall": wall_time}))