Skip to content

Commit 8adb7c1

Browse files
committed
Merge branch 'project-euler' of https://github.com/Iqrar99/Python into project-euler
2 parents a0a2941 + d30669b commit 8adb7c1

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

project_euler/problem_49/sol1.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
3 nested loops since we know the answer will be 12 digits.
2727
"""
2828

29-
from math import sqrt, floor
3029
from itertools import permutations
30+
from math import floor, sqrt
3131

3232

3333
def is_prime(number: int) -> bool:
@@ -107,10 +107,14 @@ def solution():
107107
for i in range(length):
108108
for j in range(i + 1, length):
109109
for k in range(j + 1, length):
110-
if abs(candidate[i] - candidate[j]) == abs(candidate[j] - candidate[k]) \
111-
and len(set([candidate[i], candidate[j], candidate[k]])) == 3:
110+
if (
111+
abs(candidate[i] - candidate[j])
112+
== abs(candidate[j] - candidate[k])
113+
and len(set([candidate[i], candidate[j], candidate[k]])) == 3
114+
):
112115
passed.append(
113-
sorted([candidate[i], candidate[j], candidate[k]]))
116+
sorted([candidate[i], candidate[j], candidate[k]])
117+
)
114118
found = True
115119

116120
if found:

project_euler/problem_50/sol1.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
Then, use sliding window to get the answer.
2626
"""
2727

28-
from math import sqrt, floor
28+
from math import floor, sqrt
2929

3030

3131
def is_prime(number: int) -> bool:
@@ -56,20 +56,20 @@ def solution():
5656
997651
5757
"""
5858

59-
prime_list = [2] + [x for x in range(3, 10**6, 2) if is_prime(x)]
59+
prime_list = [2] + [x for x in range(3, 10 ** 6, 2) if is_prime(x)]
6060

6161
cumulative_sum = []
6262
tmp = 0
6363
for x in prime_list:
6464
tmp += x
65-
if tmp < 10**6:
65+
if tmp < 10 ** 6:
6666
cumulative_sum.append(tmp)
6767
else:
6868
break
6969

7070
upper_limit_idx = 0
7171
for i in range(len(prime_list)):
72-
if prime_list[i] < 10**6:
72+
if prime_list[i] < 10 ** 6:
7373
upper_limit_idx = i
7474
else:
7575
break
@@ -96,5 +96,5 @@ def solution():
9696
return answer
9797

9898

99-
if __name__ == '__main__':
99+
if __name__ == "__main__":
100100
print(solution())

0 commit comments

Comments
 (0)