From 965b1ff7dfac4806d61e39dfbbdfb6c5c165c0a7 Mon Sep 17 00:00:00 2001 From: Maxim Smolskiy Date: Sun, 31 Oct 2021 13:36:53 +0300 Subject: [PATCH] Improve Project Euler problem 078 solution 1 (#5708) * Add solution doctests * Improve solution function --- project_euler/problem_078/sol1.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/project_euler/problem_078/sol1.py b/project_euler/problem_078/sol1.py index f92cf0f40..7e5938c4c 100644 --- a/project_euler/problem_078/sol1.py +++ b/project_euler/problem_078/sol1.py @@ -21,6 +21,12 @@ import itertools def solution(number: int = 1000000) -> int: """ + >>> solution(1) + 1 + + >>> solution(9) + 14 + >>> solution() 55374 """ @@ -34,6 +40,7 @@ def solution(number: int = 1000000) -> int: if index > i: break item += partitions[i - index] * sign + item %= number index += j if index > i: break