Skip to content

Commit

Permalink
final solution
Browse files Browse the repository at this point in the history
  • Loading branch information
ikostan committed Nov 24, 2024
1 parent acda7a8 commit 5f926a0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
12 changes: 12 additions & 0 deletions kyu_6/sums_of_parts/solution.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,17 @@ def parts_sums(ls: list) -> list:
:param ls:
:return:
"""
# empty list should return 0
if not ls:
return [0]

result: list = []
ls_sum: int = sum(ls)
result.append(ls_sum)

for num in ls:
n = ls_sum - num
result.append(n)
ls_sum = n

return result
1 change: 1 addition & 0 deletions kyu_6/sums_of_parts/test_solution.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def test_sjf(self):
"</p>")
# pylint: enable-msg=R0801
test_data: tuple = (
([], [0]),
([1, 2, 3, 4, 5, 6], [21, 20, 18, 15, 11, 6, 0]),
([0, 1, 3, 6, 10], [20, 20, 19, 16, 10, 0]),
([744125, 935, 407, 454, 430, 90, 144, 6710213, 889, 810, 2579358],
Expand Down

0 comments on commit 5f926a0

Please sign in to comment.