-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgpt4_solution.py
More file actions
38 lines (30 loc) · 931 Bytes
/
Copy pathgpt4_solution.py
File metadata and controls
38 lines (30 loc) · 931 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 gpt4
def solution():
def recurring_cycle_length(d):
remainders = {}
value = 1
position = 0
while value != 0:
if value in remainders:
return position - remainders[value]
remainders[value] = position
value *= 10
value %= d
position += 1
return 0
max_length = 0
result = 0
for d in range(2, 1000):
cycle_length = recurring_cycle_length(d)
if cycle_length > max_length:
max_length = cycle_length
result = d
return result
# END - CODE GENERATED BY gpt4
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}))