From a26071d295b552b7ef4539d237fb73770285219d Mon Sep 17 00:00:00 2001 From: Freddy Pringle Date: Fri, 9 Oct 2020 18:38:00 +0200 Subject: [PATCH 1/9] Added solution for Project Euler problem 77. Fixes: 2695 --- project_euler/problem_77/__init__.py | 0 project_euler/problem_77/sol1.py | 62 ++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 project_euler/problem_77/__init__.py create mode 100644 project_euler/problem_77/sol1.py diff --git a/project_euler/problem_77/__init__.py b/project_euler/problem_77/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/project_euler/problem_77/sol1.py b/project_euler/problem_77/sol1.py new file mode 100644 index 000000000000..64e72b5aa309 --- /dev/null +++ b/project_euler/problem_77/sol1.py @@ -0,0 +1,62 @@ +""" +It is possible to write ten as the sum of primes in exactly five different ways: + +7 + 3 +5 + 5 +5 + 3 + 2 +3 + 3 + 2 + 2 +2 + 2 + 2 + 2 + 2 + +What is the first value which can be written as the sum of primes in over +five thousand different ways? +""" + +primes = set(range(3, 100, 2)) +primes.add(2) +for i in range(3, 100, 2): + if i not in primes: + continue + primes.difference_update(set(range(i * i, 100, i))) + +CACHE_PARTITION = {0: {1}} + + +def partition(n: int) -> set: + """ + Return a set of integers corresponding to unique prime partitions of n. + The unique prime partitions can be represented as unique prime decompositions, + e.g. (7+3) <-> 7*3 = 12, (3+3+2+2) = 3*3*2*2 = 36 + >>> partition(10) + {32, 36, 21, 25, 30} + >>> partition(15) + {192, 160, 105, 44, 112, 243, 180, 150, 216, 26, 125, 126} + """ + if n < 0: + return set() + if n in CACHE_PARTITION: + return CACHE_PARTITION[n] + + ret = set() + for prime in primes: + if prime > n: + continue + for sub in partition(n - prime): + ret.add(sub * prime) + + CACHE_PARTITION[n] = ret + return ret + + +def solution() -> int: + """ + Return the smallest integer that can be written as the sum of primes in over + 5000 unique ways. + """ + for n in range(1, 100): + if len(partition(n)) > 5000: + return n + return 0 + + +if __name__ == "__main__": + print(solution()) From b9fb17f6e003bbe53fc1ab9c668d0470aab4f777 Mon Sep 17 00:00:00 2001 From: Freddy Pringle Date: Thu, 15 Oct 2020 10:54:15 +0200 Subject: [PATCH 2/9] Update docstrings, doctest, type annotations and 0-padding in directory name. Reference: #3256 --- .../{problem_77 => problem_077}/__init__.py | 0 project_euler/{problem_77 => problem_077}/sol1.py | 12 ++++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) rename project_euler/{problem_77 => problem_077}/__init__.py (100%) rename project_euler/{problem_77 => problem_077}/sol1.py (86%) diff --git a/project_euler/problem_77/__init__.py b/project_euler/problem_077/__init__.py similarity index 100% rename from project_euler/problem_77/__init__.py rename to project_euler/problem_077/__init__.py diff --git a/project_euler/problem_77/sol1.py b/project_euler/problem_077/sol1.py similarity index 86% rename from project_euler/problem_77/sol1.py rename to project_euler/problem_077/sol1.py index 64e72b5aa309..294aae882ac9 100644 --- a/project_euler/problem_77/sol1.py +++ b/project_euler/problem_077/sol1.py @@ -1,4 +1,6 @@ """ +Project Euler Problem 77: https://projecteuler.net/problem=77 + It is possible to write ten as the sum of primes in exactly five different ways: 7 + 3 @@ -47,16 +49,18 @@ def partition(n: int) -> set: return ret -def solution() -> int: +def solution(m: int = 5000) -> int: """ Return the smallest integer that can be written as the sum of primes in over - 5000 unique ways. + m unique ways. + >>> solution(500) + 45 """ for n in range(1, 100): - if len(partition(n)) > 5000: + if len(partition(n)) > m: return n return 0 if __name__ == "__main__": - print(solution()) + print(f"{solution() = }") From 28bb9250b2f6554b02d255474a709a54e94f44d4 Mon Sep 17 00:00:00 2001 From: Freddy Pringle Date: Thu, 29 Oct 2020 20:55:18 +0100 Subject: [PATCH 3/9] Implemented lru_cache, better type hints, more doctests for problem 77 --- project_euler/problem_077/sol1.py | 43 +++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 14 deletions(-) diff --git a/project_euler/problem_077/sol1.py b/project_euler/problem_077/sol1.py index 294aae882ac9..a427af79e805 100644 --- a/project_euler/problem_077/sol1.py +++ b/project_euler/problem_077/sol1.py @@ -13,17 +13,24 @@ five thousand different ways? """ -primes = set(range(3, 100, 2)) +from functools import lru_cache +from math import ceil +from typing import Optional, Set + +NUM_PRIMES = 100 + +primes = set(range(3, NUM_PRIMES, 2)) primes.add(2) -for i in range(3, 100, 2): - if i not in primes: - continue - primes.difference_update(set(range(i * i, 100, i))) +prime: int -CACHE_PARTITION = {0: {1}} +for prime in range(3, ceil(NUM_PRIMES ** 0.5), 2): + if prime not in primes: + continue + primes.difference_update(set(range(prime * prime, NUM_PRIMES, prime))) -def partition(n: int) -> set: +@lru_cache(maxsize=100) +def partition(n: int) -> Set[int]: """ Return a set of integers corresponding to unique prime partitions of n. The unique prime partitions can be represented as unique prime decompositions, @@ -32,34 +39,42 @@ def partition(n: int) -> set: {32, 36, 21, 25, 30} >>> partition(15) {192, 160, 105, 44, 112, 243, 180, 150, 216, 26, 125, 126} + >>> len(partition(20)) + 26 """ if n < 0: return set() - if n in CACHE_PARTITION: - return CACHE_PARTITION[n] + elif n == 0: + return {1} + + ret: Set[int] = set() + prime: int + sub: int - ret = set() for prime in primes: if prime > n: continue for sub in partition(n - prime): ret.add(sub * prime) - CACHE_PARTITION[n] = ret return ret -def solution(m: int = 5000) -> int: +def solution(m: int = 5000) -> Optional[int]: """ Return the smallest integer that can be written as the sum of primes in over m unique ways. + >>> solution(4) + 10 >>> solution(500) 45 + >>> solution(1000) + 53 """ - for n in range(1, 100): + for n in range(1, NUM_PRIMES): if len(partition(n)) > m: return n - return 0 + return None if __name__ == "__main__": From 9b5237c99af7f6a2e79b9a15f6a21d2e7bafadcd Mon Sep 17 00:00:00 2001 From: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> Date: Thu, 29 Oct 2020 19:56:24 +0000 Subject: [PATCH 4/9] updating DIRECTORY.md --- DIRECTORY.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/DIRECTORY.md b/DIRECTORY.md index d3a378c3a2ee..554d5c0dc472 100644 --- a/DIRECTORY.md +++ b/DIRECTORY.md @@ -473,6 +473,7 @@ * [Binary Exponentiation 2](https://github.com/TheAlgorithms/Python/blob/master/other/binary_exponentiation_2.py) * [Detecting English Programmatically](https://github.com/TheAlgorithms/Python/blob/master/other/detecting_english_programmatically.py) * [Dijkstra Bankers Algorithm](https://github.com/TheAlgorithms/Python/blob/master/other/dijkstra_bankers_algorithm.py) + * [Doomsday](https://github.com/TheAlgorithms/Python/blob/master/other/doomsday.py) * [Euclidean Gcd](https://github.com/TheAlgorithms/Python/blob/master/other/euclidean_gcd.py) * [Fischer Yates Shuffle](https://github.com/TheAlgorithms/Python/blob/master/other/fischer_yates_shuffle.py) * [Frequency Finder](https://github.com/TheAlgorithms/Python/blob/master/other/frequency_finder.py) @@ -529,11 +530,12 @@ * [Sol2](https://github.com/TheAlgorithms/Python/blob/master/project_euler/problem_06/sol2.py) * [Sol3](https://github.com/TheAlgorithms/Python/blob/master/project_euler/problem_06/sol3.py) * [Sol4](https://github.com/TheAlgorithms/Python/blob/master/project_euler/problem_06/sol4.py) - * [Test Solutions](https://github.com/TheAlgorithms/Python/blob/master/project_euler/problem_06/test_solutions.py) * Problem 07 * [Sol1](https://github.com/TheAlgorithms/Python/blob/master/project_euler/problem_07/sol1.py) * [Sol2](https://github.com/TheAlgorithms/Python/blob/master/project_euler/problem_07/sol2.py) * [Sol3](https://github.com/TheAlgorithms/Python/blob/master/project_euler/problem_07/sol3.py) + * Problem 077 + * [Sol1](https://github.com/TheAlgorithms/Python/blob/master/project_euler/problem_077/sol1.py) * Problem 08 * [Sol1](https://github.com/TheAlgorithms/Python/blob/master/project_euler/problem_08/sol1.py) * [Sol2](https://github.com/TheAlgorithms/Python/blob/master/project_euler/problem_08/sol2.py) @@ -595,11 +597,11 @@ * Problem 26 * [Sol1](https://github.com/TheAlgorithms/Python/blob/master/project_euler/problem_26/sol1.py) * Problem 27 - * [Problem 27 Sol1](https://github.com/TheAlgorithms/Python/blob/master/project_euler/problem_27/problem_27_sol1.py) + * [Sol1](https://github.com/TheAlgorithms/Python/blob/master/project_euler/problem_27/sol1.py) * Problem 28 * [Sol1](https://github.com/TheAlgorithms/Python/blob/master/project_euler/problem_28/sol1.py) * Problem 29 - * [Solution](https://github.com/TheAlgorithms/Python/blob/master/project_euler/problem_29/solution.py) + * [Sol1](https://github.com/TheAlgorithms/Python/blob/master/project_euler/problem_29/sol1.py) * Problem 30 * [Sol1](https://github.com/TheAlgorithms/Python/blob/master/project_euler/problem_30/sol1.py) * Problem 31 @@ -656,6 +658,8 @@ * [Sol1](https://github.com/TheAlgorithms/Python/blob/master/project_euler/problem_63/sol1.py) * Problem 67 * [Sol1](https://github.com/TheAlgorithms/Python/blob/master/project_euler/problem_67/sol1.py) + * Problem 71 + * [Sol1](https://github.com/TheAlgorithms/Python/blob/master/project_euler/problem_71/sol1.py) * Problem 76 * [Sol1](https://github.com/TheAlgorithms/Python/blob/master/project_euler/problem_76/sol1.py) * Problem 97 From 307a5ef5e0ce3debf4cbdce229b737e103232cf8 Mon Sep 17 00:00:00 2001 From: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> Date: Thu, 29 Oct 2020 19:59:10 +0000 Subject: [PATCH 5/9] updating DIRECTORY.md --- DIRECTORY.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/DIRECTORY.md b/DIRECTORY.md index ec2ec91535a9..30bd4434605e 100644 --- a/DIRECTORY.md +++ b/DIRECTORY.md @@ -517,8 +517,7 @@ * [Primelib](https://github.com/TheAlgorithms/Python/blob/master/other/primelib.py) * [Scoring Algorithm](https://github.com/TheAlgorithms/Python/blob/master/other/scoring_algorithm.py) * [Sdes](https://github.com/TheAlgorithms/Python/blob/master/other/sdes.py) - * [Sierpinski Triangle](https://github.com/TheAlgorithms/Python/blob/ - /other/sierpinski_triangle.py) + * [Sierpinski Triangle](https://github.com/TheAlgorithms/Python/blob/master/other/sierpinski_triangle.py) * [Tower Of Hanoi](https://github.com/TheAlgorithms/Python/blob/master/other/tower_of_hanoi.py) * [Triplet Sum](https://github.com/TheAlgorithms/Python/blob/master/other/triplet_sum.py) * [Two Pointer](https://github.com/TheAlgorithms/Python/blob/master/other/two_pointer.py) @@ -675,6 +674,8 @@ * [Sol1](https://github.com/TheAlgorithms/Python/blob/master/project_euler/problem_056/sol1.py) * Problem 057 * [Sol1](https://github.com/TheAlgorithms/Python/blob/master/project_euler/problem_057/sol1.py) + * Problem 058 + * [Sol1](https://github.com/TheAlgorithms/Python/blob/master/project_euler/problem_058/sol1.py) * Problem 062 * [Sol1](https://github.com/TheAlgorithms/Python/blob/master/project_euler/problem_062/sol1.py) * Problem 063 @@ -702,6 +703,8 @@ * [Sol1](https://github.com/TheAlgorithms/Python/blob/master/project_euler/problem_080/sol1.py) * Problem 081 * [Sol1](https://github.com/TheAlgorithms/Python/blob/master/project_euler/problem_081/sol1.py) + * Problem 087 + * [Sol1](https://github.com/TheAlgorithms/Python/blob/master/project_euler/problem_087/sol1.py) * Problem 091 * [Sol1](https://github.com/TheAlgorithms/Python/blob/master/project_euler/problem_091/sol1.py) * Problem 097 @@ -820,6 +823,7 @@ * [Prefix Function](https://github.com/TheAlgorithms/Python/blob/master/strings/prefix_function.py) * [Rabin Karp](https://github.com/TheAlgorithms/Python/blob/master/strings/rabin_karp.py) * [Remove Duplicate](https://github.com/TheAlgorithms/Python/blob/master/strings/remove_duplicate.py) + * [Reverse Letters](https://github.com/TheAlgorithms/Python/blob/master/strings/reverse_letters.py) * [Reverse Words](https://github.com/TheAlgorithms/Python/blob/master/strings/reverse_words.py) * [Split](https://github.com/TheAlgorithms/Python/blob/master/strings/split.py) * [Swap Case](https://github.com/TheAlgorithms/Python/blob/master/strings/swap_case.py) From d0fb8373bc5fa6e2d3ab097875fdd9e06083250c Mon Sep 17 00:00:00 2001 From: Freddy Pringle Date: Fri, 9 Oct 2020 18:38:00 +0200 Subject: [PATCH 6/9] Added solution for Project Euler problem 77. Fixes: 2695 --- project_euler/problem_77/__init__.py | 0 project_euler/problem_77/sol1.py | 62 ++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 project_euler/problem_77/__init__.py create mode 100644 project_euler/problem_77/sol1.py diff --git a/project_euler/problem_77/__init__.py b/project_euler/problem_77/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/project_euler/problem_77/sol1.py b/project_euler/problem_77/sol1.py new file mode 100644 index 000000000000..64e72b5aa309 --- /dev/null +++ b/project_euler/problem_77/sol1.py @@ -0,0 +1,62 @@ +""" +It is possible to write ten as the sum of primes in exactly five different ways: + +7 + 3 +5 + 5 +5 + 3 + 2 +3 + 3 + 2 + 2 +2 + 2 + 2 + 2 + 2 + +What is the first value which can be written as the sum of primes in over +five thousand different ways? +""" + +primes = set(range(3, 100, 2)) +primes.add(2) +for i in range(3, 100, 2): + if i not in primes: + continue + primes.difference_update(set(range(i * i, 100, i))) + +CACHE_PARTITION = {0: {1}} + + +def partition(n: int) -> set: + """ + Return a set of integers corresponding to unique prime partitions of n. + The unique prime partitions can be represented as unique prime decompositions, + e.g. (7+3) <-> 7*3 = 12, (3+3+2+2) = 3*3*2*2 = 36 + >>> partition(10) + {32, 36, 21, 25, 30} + >>> partition(15) + {192, 160, 105, 44, 112, 243, 180, 150, 216, 26, 125, 126} + """ + if n < 0: + return set() + if n in CACHE_PARTITION: + return CACHE_PARTITION[n] + + ret = set() + for prime in primes: + if prime > n: + continue + for sub in partition(n - prime): + ret.add(sub * prime) + + CACHE_PARTITION[n] = ret + return ret + + +def solution() -> int: + """ + Return the smallest integer that can be written as the sum of primes in over + 5000 unique ways. + """ + for n in range(1, 100): + if len(partition(n)) > 5000: + return n + return 0 + + +if __name__ == "__main__": + print(solution()) From 9e0b3ef0bc371b5fa5074c1d314ffd06adba4f59 Mon Sep 17 00:00:00 2001 From: Freddy Pringle Date: Thu, 15 Oct 2020 10:54:15 +0200 Subject: [PATCH 7/9] Update docstrings, doctest, type annotations and 0-padding in directory name. Reference: #3256 --- .../{problem_77 => problem_077}/__init__.py | 0 project_euler/{problem_77 => problem_077}/sol1.py | 12 ++++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) rename project_euler/{problem_77 => problem_077}/__init__.py (100%) rename project_euler/{problem_77 => problem_077}/sol1.py (86%) diff --git a/project_euler/problem_77/__init__.py b/project_euler/problem_077/__init__.py similarity index 100% rename from project_euler/problem_77/__init__.py rename to project_euler/problem_077/__init__.py diff --git a/project_euler/problem_77/sol1.py b/project_euler/problem_077/sol1.py similarity index 86% rename from project_euler/problem_77/sol1.py rename to project_euler/problem_077/sol1.py index 64e72b5aa309..294aae882ac9 100644 --- a/project_euler/problem_77/sol1.py +++ b/project_euler/problem_077/sol1.py @@ -1,4 +1,6 @@ """ +Project Euler Problem 77: https://projecteuler.net/problem=77 + It is possible to write ten as the sum of primes in exactly five different ways: 7 + 3 @@ -47,16 +49,18 @@ def partition(n: int) -> set: return ret -def solution() -> int: +def solution(m: int = 5000) -> int: """ Return the smallest integer that can be written as the sum of primes in over - 5000 unique ways. + m unique ways. + >>> solution(500) + 45 """ for n in range(1, 100): - if len(partition(n)) > 5000: + if len(partition(n)) > m: return n return 0 if __name__ == "__main__": - print(solution()) + print(f"{solution() = }") From 7b43475e73cc012acca5d6e998b75ac4fe87135e Mon Sep 17 00:00:00 2001 From: Freddy Pringle Date: Thu, 29 Oct 2020 20:55:18 +0100 Subject: [PATCH 8/9] Implemented lru_cache, better type hints, more doctests for problem 77 --- project_euler/problem_077/sol1.py | 43 +++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 14 deletions(-) diff --git a/project_euler/problem_077/sol1.py b/project_euler/problem_077/sol1.py index 294aae882ac9..a427af79e805 100644 --- a/project_euler/problem_077/sol1.py +++ b/project_euler/problem_077/sol1.py @@ -13,17 +13,24 @@ five thousand different ways? """ -primes = set(range(3, 100, 2)) +from functools import lru_cache +from math import ceil +from typing import Optional, Set + +NUM_PRIMES = 100 + +primes = set(range(3, NUM_PRIMES, 2)) primes.add(2) -for i in range(3, 100, 2): - if i not in primes: - continue - primes.difference_update(set(range(i * i, 100, i))) +prime: int -CACHE_PARTITION = {0: {1}} +for prime in range(3, ceil(NUM_PRIMES ** 0.5), 2): + if prime not in primes: + continue + primes.difference_update(set(range(prime * prime, NUM_PRIMES, prime))) -def partition(n: int) -> set: +@lru_cache(maxsize=100) +def partition(n: int) -> Set[int]: """ Return a set of integers corresponding to unique prime partitions of n. The unique prime partitions can be represented as unique prime decompositions, @@ -32,34 +39,42 @@ def partition(n: int) -> set: {32, 36, 21, 25, 30} >>> partition(15) {192, 160, 105, 44, 112, 243, 180, 150, 216, 26, 125, 126} + >>> len(partition(20)) + 26 """ if n < 0: return set() - if n in CACHE_PARTITION: - return CACHE_PARTITION[n] + elif n == 0: + return {1} + + ret: Set[int] = set() + prime: int + sub: int - ret = set() for prime in primes: if prime > n: continue for sub in partition(n - prime): ret.add(sub * prime) - CACHE_PARTITION[n] = ret return ret -def solution(m: int = 5000) -> int: +def solution(m: int = 5000) -> Optional[int]: """ Return the smallest integer that can be written as the sum of primes in over m unique ways. + >>> solution(4) + 10 >>> solution(500) 45 + >>> solution(1000) + 53 """ - for n in range(1, 100): + for n in range(1, NUM_PRIMES): if len(partition(n)) > m: return n - return 0 + return None if __name__ == "__main__": From d0477e9a0b456c9bf8fe48f09ca7208b80799ad6 Mon Sep 17 00:00:00 2001 From: Freddy Pringle Date: Sat, 7 Nov 2020 15:04:42 +0100 Subject: [PATCH 9/9] better variable names --- project_euler/problem_077/sol1.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/project_euler/problem_077/sol1.py b/project_euler/problem_077/sol1.py index a427af79e805..e92992a90ab3 100644 --- a/project_euler/problem_077/sol1.py +++ b/project_euler/problem_077/sol1.py @@ -30,7 +30,7 @@ @lru_cache(maxsize=100) -def partition(n: int) -> Set[int]: +def partition(number_to_partition: int) -> Set[int]: """ Return a set of integers corresponding to unique prime partitions of n. The unique prime partitions can be represented as unique prime decompositions, @@ -42,9 +42,9 @@ def partition(n: int) -> Set[int]: >>> len(partition(20)) 26 """ - if n < 0: + if number_to_partition < 0: return set() - elif n == 0: + elif number_to_partition == 0: return {1} ret: Set[int] = set() @@ -52,15 +52,15 @@ def partition(n: int) -> Set[int]: sub: int for prime in primes: - if prime > n: + if prime > number_to_partition: continue - for sub in partition(n - prime): + for sub in partition(number_to_partition - prime): ret.add(sub * prime) return ret -def solution(m: int = 5000) -> Optional[int]: +def solution(number_unique_partitions: int = 5000) -> Optional[int]: """ Return the smallest integer that can be written as the sum of primes in over m unique ways. @@ -71,9 +71,9 @@ def solution(m: int = 5000) -> Optional[int]: >>> solution(1000) 53 """ - for n in range(1, NUM_PRIMES): - if len(partition(n)) > m: - return n + for number_to_partition in range(1, NUM_PRIMES): + if len(partition(number_to_partition)) > number_unique_partitions: + return number_to_partition return None