Skip to content

Commit

Permalink
2 More
Browse files Browse the repository at this point in the history
  • Loading branch information
flexo333 committed Jun 22, 2020
1 parent 187f495 commit 7807a94
Show file tree
Hide file tree
Showing 7 changed files with 616 additions and 127 deletions.
7 changes: 7 additions & 0 deletions .idea/dictionaries/willb.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

98 changes: 52 additions & 46 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 6 additions & 4 deletions EulerProject.sublime-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
"file": "P060.py",
"settings":
{
"buffer_size": 0,
"buffer_size": 3611,
"encoding": "UTF-8",
"line_ending": "Windows"
}
Expand Down Expand Up @@ -253,6 +253,8 @@
],
"file_history":
[
"/C/Code/Euler/.git/COMMIT_EDITMSG",
"/C/Code/Euler/.git/rebase-merge/git-rebase-todo",
"/C/Code/Euler/P058.py",
"/C/Code/Euler/P057.py",
"/C/Code/Euler/P055.py",
Expand Down Expand Up @@ -398,7 +400,7 @@
"semi_transient": false,
"settings":
{
"buffer_size": 0,
"buffer_size": 3611,
"regions":
{
},
Expand All @@ -416,7 +418,7 @@
"translate_tabs_to_spaces": true
},
"translation.x": 0.0,
"translation.y": 591.2,
"translation.y": 591.0,
"zoom_level": 1.0
},
"stack_index": 2,
Expand Down Expand Up @@ -446,7 +448,7 @@
"translate_tabs_to_spaces": true
},
"translation.x": 0.0,
"translation.y": 1124.8,
"translation.y": 1125.0,
"zoom_level": 1.0
},
"stack_index": 0,
Expand Down
21 changes: 20 additions & 1 deletion P060.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def problem_1():

@timeit
def problem():
primes = sorted(list(set(ps(8000))))
primes = sorted(list(set(ps(12000))))
print('The number of primes is {}'.format(len(primes)))
# A Python program to print all
# combinations of given length
Expand Down Expand Up @@ -128,7 +128,26 @@ def problem():
new_list.append(my_set)
print(my_set)

max_prime = 34429 + 1

@eulertools.timeit
def problem_notmine():

for a in range(13, max_prime, 2):
if eulertools.is_prime(a):
for b in range(a + 2, max_prime-a, 2):
if eulertools.is_prime(b) and eulertools.is_prime(int(str(a) + str(b))) and eulertools.is_prime(int(str(b) + str(a))):
for c in range(b + 2, max_prime-a-b, 2):
if eulertools.is_prime(c) and eulertools.is_prime(int(str(a) + str(c))) and eulertools.is_prime(int(str(b) + str(c))) and eulertools.is_prime(int(str(c) + str(a))) and eulertools.is_prime(int(str(c) + str(b))):
for d in range(c + 2, max_prime-a-b-c, 2):
if eulertools.is_prime(d) and eulertools.is_prime(int(str(a) + str(d))) and eulertools.is_prime(int(str(b) + str(d))) and eulertools.is_prime(int(str(c) + str(d))) and eulertools.is_prime(int(str(d) + str(a))) and eulertools.is_prime(int(str(d) + str(b))) and eulertools.is_prime(int(str(d) + str(c))):
for e in range(d + 2, max_prime-a-b-c-d, 2):
if eulertools.is_prime(e) and eulertools.is_prime(int(str(a) + str(e))) and eulertools.is_prime(int(str(b) + str(e))) and eulertools.is_prime(int(str(c) + str(e))) and eulertools.is_prime(int(str(d) + str(e))) and eulertools.is_prime(int(str(e) + str(a))) and eulertools.is_prime(int(str(e) + str(b))) and eulertools.is_prime(int(str(e) + str(c))) and eulertools.is_prime(int(str(e) + str(d))):
return a + b + c + d + e


if __name__ == "__main__":
print(problem())
# print(168*167*166)


43 changes: 43 additions & 0 deletions P061.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# import eulertools as et
from eulertools import timeit

"""
"""

TRIANGLES = [int(n * (n + 1) / 2) for n in range(150) if 999 < n * (n + 1) / 2 < 9999]
SQUARES = [n ** 2 for n in range(110) if 999 < n ** 2 < 9999]
PENTAGONALS = [int(n * (3 * n - 1) / 2) for n in range(100) if 999 < n * (3 * n - 1) / 2 < 9999]
HEXAGONALS = [n * (2 * n - 1) for n in range(100) if 999 < n * (2 * n - 1) < 9999]
HEPTAGONALS = [int(n * (5 * n - 3) / 2) for n in range(100) if 999 < n * (5 * n - 3) / 2 < 9999]
OCTAGONALS = [n * (3 * n - 2) for n in range(100) if 999 < n * (3 * n - 2) < 9999]

print(len(TRIANGLES), len(SQUARES), len(PENTAGONALS), len(HEXAGONALS), len(HEPTAGONALS), len(OCTAGONALS))


def is_cyclical(n, m):
if n%100 == int(m / 100):
return True
else:
return False

@timeit
def problem():
for triangle in TRIANGLES:
for square in SQUARES:
if is_cyclical(triangle, square):
for pentagonal in PENTAGONALS:
if is_cyclical(square, pentagonal):
for hexagonal in HEXAGONALS:
if str(pentagonal)[-2:] == str(hexagonal)[0:2]:
for heptagonal in HEPTAGONALS:
if str(hexagonal)[-2:] == str(heptagonal)[0:2]:
for octagonal in OCTAGONALS:
if str(heptagonal)[-2:] == str(octagonal)[0:2]:
# if str(octagonal)[-2:] == str(triangle)[0:2]:
print(triangle, square, pentagonal, hexagonal, heptagonal, octagonal)


if __name__ == "__main__":
result = problem()
print(result)

Loading

0 comments on commit 7807a94

Please sign in to comment.