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