-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgpt3_solution.py
More file actions
26 lines (23 loc) · 779 Bytes
/
Copy pathgpt3_solution.py
File metadata and controls
26 lines (23 loc) · 779 Bytes
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
import json
import time
# START - CODE GENERATED BY gpt3
def solution():
t, p, h = 285, 165, 143
triangle, pentagonal, hexagonal = 40755, 40755, 40755
while True:
t += 1
triangle = t * (t + 1) // 2
while pentagonal < triangle:
p += 1
pentagonal = p * (3 * p - 1) // 2
while hexagonal < triangle:
h += 1
hexagonal = h * (2 * h - 1)
if triangle == pentagonal == hexagonal:
return triangle
# 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}))