Skip to content

Added solution for Project Euler problem 74. #3125

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 3 commits into from
Oct 15, 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
Added doctest for solution() in project_euler/problem_74/sol1.py
  • Loading branch information
fpringle committed Oct 10, 2020
commit 8afd3795ad44f6093d258d67a42a5b1dd183ebe6
6 changes: 4 additions & 2 deletions project_euler/problem_74/sol1.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,14 @@ def chain_length(n: int, previous: set = None) -> int:
return ret


def solution(n: int = 60) -> int:
def solution(num_terms: int = 60, max_start: int = 1000000) -> int:
"""
Return the number of chains with a starting number below one million which
contain exactly n non-repeating terms.
>>> solution(10,1000)
28
"""
return sum(1 for i in range(1, 1000000) if chain_length(i) == n)
return sum(1 for i in range(1, max_start) if chain_length(i) == num_terms)


if __name__ == "__main__":
Expand Down