diff --git a/kyu_6/sums_of_parts/solution.py b/kyu_6/sums_of_parts/solution.py index a6872651a58..de42460c068 100644 --- a/kyu_6/sums_of_parts/solution.py +++ b/kyu_6/sums_of_parts/solution.py @@ -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 diff --git a/kyu_6/sums_of_parts/test_solution.py b/kyu_6/sums_of_parts/test_solution.py index e683e2f5bc4..43b93a73526 100644 --- a/kyu_6/sums_of_parts/test_solution.py +++ b/kyu_6/sums_of_parts/test_solution.py @@ -51,6 +51,7 @@ def test_sjf(self): "

") # 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],