-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgpt3_solution.py
More file actions
38 lines (33 loc) · 904 Bytes
/
Copy pathgpt3_solution.py
File metadata and controls
38 lines (33 loc) · 904 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
27
28
29
30
31
32
33
34
35
36
37
38
import json
import time
# START - CODE GENERATED BY gpt3
import math
def solution():
def prime_factors(n):
factors = set()
while n % 2 == 0:
factors.add(2)
n //= 2
for i in range(3, int(math.sqrt(n))+1, 2):
while n % i == 0:
factors.add(i)
n //= i
if n > 2:
factors.add(n)
return factors
count = 0
num = 1
while True:
if len(prime_factors(num)) == 4:
count += 1
else:
count = 0
if count == 4:
return num - 3
num += 1
# 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}))