Skip to content

Added solution for Project Euler problem 38. #3115

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

Merged
merged 5 commits into from
Oct 24, 2020
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Changed just-in-case return value for solution() to None.
  • Loading branch information
fpringle committed Oct 15, 2020
commit 44c3decfa54da99f61078cb532869f9803dcf7b3
9 changes: 6 additions & 3 deletions project_euler/problem_038/sol1.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
concatenated product of an integer with (1,2, ... , n) where n > 1?
"""

from __future__ import annotations

from typing import Union


def is_9_pandigital(n: int) -> bool:
"""
Expand All @@ -33,7 +37,7 @@ def is_9_pandigital(n: int) -> bool:
return len(s) == 9 and set(s) == set("123456789")


def solution() -> int:
def solution() -> Union[int, None]:
"""
Return the largest 1 to 9 pandigital 9-digital number that can be formed as the
concatenated product of an integer with (1,2,...,n) where n > 1.
Expand Down Expand Up @@ -69,8 +73,7 @@ def solution() -> int:
if is_9_pandigital(candidate):
return candidate

# just in case
return 192384576
return None


if __name__ == "__main__":
Expand Down