Skip to content

Hacktoberfest 2020: Rename method for project_euler/problem_45 & project_euler/problem_46 #3043

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions project_euler/problem_45/sol1.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ def is_pentagonal(n: int) -> bool:
return ((1 + root) / 6) % 1 == 0


def compute_num(start: int = 144) -> int:
def solution(start: int = 144) -> int:
"""
Returns the next number which is traingular, pentagonal and hexagonal.
>>> compute_num(144)
>>> solution(144)
1533776805
"""
n = start
Expand All @@ -54,4 +54,4 @@ def compute_num(start: int = 144) -> int:


if __name__ == "__main__":
print(f"{compute_num(144)} = ")
print(f"{solution(144) = }")
16 changes: 8 additions & 8 deletions project_euler/problem_46/sol1.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,23 +43,23 @@ def is_prime(n: int) -> bool:
odd_composites = [num for num in range(3, len(seive), 2) if not is_prime(num)]


def compute_nums(n: int) -> list[int]:
def solution(n: int = 1) -> list[int]:
"""
Returns a list of first n odd composite numbers which do
not follow the conjecture.
>>> compute_nums(1)
>>> solution(1)
[5777]
>>> compute_nums(2)
>>> solution(2)
[5777, 5993]
>>> compute_nums(0)
>>> solution(0)
Traceback (most recent call last):
...
ValueError: n must be >= 0
>>> compute_nums("a")
>>> solution("a")
Traceback (most recent call last):
...
ValueError: n must be an integer
>>> compute_nums(1.1)
>>> solution(1.1)
Traceback (most recent call last):
...
ValueError: n must be an integer
Expand All @@ -68,7 +68,7 @@ def compute_nums(n: int) -> list[int]:
if not isinstance(n, int):
raise ValueError("n must be an integer")
if n <= 0:
raise ValueError("n must be >= 0")
raise ValueError("n must be > 0")

list_nums = []
for num in range(len(odd_composites)):
Expand All @@ -85,4 +85,4 @@ def compute_nums(n: int) -> list[int]:


if __name__ == "__main__":
print(f"{compute_nums(1) = }")
print(f"{solution(1) = }")