-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgpt4_solution.py
More file actions
40 lines (32 loc) · 1.28 KB
/
Copy pathgpt4_solution.py
File metadata and controls
40 lines (32 loc) · 1.28 KB
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
39
40
import json
import time
# START - CODE GENERATED BY gpt4
def solution():
from math import gcd
def is_curious_fraction(numerator, denominator):
num_str, den_str = str(numerator), str(denominator)
if num_str[1] == '0' and den_str[1] == '0':
return False
for i in range(2):
for j in range(2):
if num_str[i] == den_str[j] and num_str[i] != '0':
new_num = int(num_str[1 - i])
new_den = int(den_str[1 - j])
if new_den != 0 and numerator * new_den == denominator * new_num:
return True
return False
product_num = 1
product_den = 1
for numerator in range(10, 100):
for denominator in range(numerator + 1, 100):
if is_curious_fraction(numerator, denominator):
product_num *= numerator
product_den *= denominator
common_divisor = gcd(product_num, product_den)
return product_den // common_divisor
# 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}))