Improve Project Euler problem 078 solution 1 (#5708)

* Add solution doctests

* Improve solution function
This commit is contained in:
Maxim Smolskiy 2021-10-31 13:36:53 +03:00 committed by GitHub
parent a94c6214ff
commit 965b1ff7df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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