Skip to content

Commit 53bdb48

Browse files
Update sol1.py
1 parent 63bffcd commit 53bdb48

File tree

1 file changed

+0
-40
lines changed

1 file changed

+0
-40
lines changed

project_euler/problem_073/sol1.py

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -19,29 +19,6 @@
1919
from math import gcd
2020

2121

22-
def slow_solution(max_d: int = 12_000) -> int:
23-
"""
24-
Returns number of fractions lie between 1/3 and 1/2 in the sorted set
25-
of reduced proper fractions for d ≤ max_d
26-
27-
>>> slow_solution(4)
28-
0
29-
30-
>>> slow_solution(5)
31-
1
32-
33-
>>> slow_solution(8)
34-
3
35-
"""
36-
37-
fractions_number = 0
38-
for d in range(max_d + 1):
39-
for n in range(d // 3 + 1, (d + 1) // 2):
40-
if gcd(n, d) == 1:
41-
fractions_number += 1
42-
return fractions_number
43-
44-
4522
def solution(max_d: int = 12_000) -> int:
4623
"""
4724
Returns number of fractions lie between 1/3 and 1/2 in the sorted set
@@ -71,22 +48,5 @@ def solution(max_d: int = 12_000) -> int:
7148
return fractions_number
7249

7350

74-
def benchmark() -> None:
75-
"""
76-
Benchmarks
77-
"""
78-
# Running performance benchmarks...
79-
# slow_solution : 21.02750190000006
80-
# solution : 15.79036830000041
81-
82-
from timeit import timeit
83-
84-
print("Running performance benchmarks...")
85-
86-
print(f"slow_solution : {timeit('slow_solution()', globals=globals(), number=10)}")
87-
print(f"solution : {timeit('solution()', globals=globals(), number=10)}")
88-
89-
9051
if __name__ == "__main__":
9152
print(f"{solution() = }")
92-
benchmark()

0 commit comments

Comments
 (0)