File tree 2 files changed +10
-10
lines changed
2 files changed +10
-10
lines changed Original file line number Diff line number Diff line change
1
+ from itertools import permutations
2
+ from math import floor , sqrt
3
+
1
4
"""
2
5
Prime permutations
3
6
26
29
3 nested loops since we know the answer will be 12 digits.
27
30
"""
28
31
29
- from itertools import permutations
30
- from math import floor , sqrt
31
-
32
32
33
33
def is_prime (number : int ) -> bool :
34
34
"""
@@ -60,15 +60,15 @@ def search(target: int, prime_list: list) -> bool:
60
60
False
61
61
"""
62
62
63
- l , r = 0 , len (prime_list ) - 1
64
- while l <= r :
65
- m = (l + r ) // 2
63
+ left , right = 0 , len (prime_list ) - 1
64
+ while left <= right :
65
+ m = (left + right ) // 2
66
66
if prime_list [m ] == target :
67
67
return True
68
68
elif prime_list [m ] < target :
69
- l = m + 1
69
+ left = m + 1
70
70
else :
71
- r = m - 1
71
+ right = m - 1
72
72
73
73
return False
74
74
Original file line number Diff line number Diff line change
1
+ from math import floor , sqrt
2
+
1
3
"""
2
4
Consecutive prime sum
3
5
25
27
Then, use sliding window to get the answer.
26
28
"""
27
29
28
- from math import floor , sqrt
29
-
30
30
31
31
def is_prime (number : int ) -> bool :
32
32
"""
You can’t perform that action at this time.
0 commit comments