mirror of
https://github.com/TheAlgorithms/Python.git
synced 2024-12-18 01:00:15 +00:00
Improve Project Euler problem 078 solution 1 (#5708)
* Add solution doctests * Improve solution function
This commit is contained in:
parent
a94c6214ff
commit
965b1ff7df
|
@ -21,6 +21,12 @@ import itertools
|
||||||
|
|
||||||
def solution(number: int = 1000000) -> int:
|
def solution(number: int = 1000000) -> int:
|
||||||
"""
|
"""
|
||||||
|
>>> solution(1)
|
||||||
|
1
|
||||||
|
|
||||||
|
>>> solution(9)
|
||||||
|
14
|
||||||
|
|
||||||
>>> solution()
|
>>> solution()
|
||||||
55374
|
55374
|
||||||
"""
|
"""
|
||||||
|
@ -34,6 +40,7 @@ def solution(number: int = 1000000) -> int:
|
||||||
if index > i:
|
if index > i:
|
||||||
break
|
break
|
||||||
item += partitions[i - index] * sign
|
item += partitions[i - index] * sign
|
||||||
|
item %= number
|
||||||
index += j
|
index += j
|
||||||
if index > i:
|
if index > i:
|
||||||
break
|
break
|
||||||
|
|
Loading…
Reference in New Issue
Block a user