-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgpt3_solution.py
More file actions
28 lines (24 loc) · 794 Bytes
/
Copy pathgpt3_solution.py
File metadata and controls
28 lines (24 loc) · 794 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
import json
import time
# START - CODE GENERATED BY gpt3
from itertools import permutations
def solution():
primes = [2, 3, 5, 7, 11, 13, 17]
total_sum = 0
for perm in permutations('0123456789'):
if perm[0] == '0':
continue
divisible = True
for i in range(7):
if int(''.join(perm[i+1:i+4])) % primes[i] != 0:
divisible = False
break
if divisible:
total_sum += int(''.join(perm))
return total_sum
# 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}))