Positive partial sums

The partial sums of a list of integers v are:

    v[0]
    v[0]+v[1]
    v[0]+v[1]+v[2]
    ...
    v[0]+v[1]+v[2]+...+v[len(v)-1]

Design a function @sumes_parcials_pos(v)@ that, given a list of integers
v, returns the list containing the positive partial sums of the list v,
that is, those that are greater than zero.

For example, if v is [0, 3, -4, -5, 7], then the partial sums are

    0
    0+3 == 3
    0+3+(-4) == -1
    0+3+(-4)+(-5) == -6
    0+3+(-4)+(-5)+7 == 1

and, therefore, the list with the two positive partial sums must be
returned

    [3, 1] == [0+3, 0+3+(-4)+(-5)+7]

DON’T use the Python function sum(v[i:j]).

Sample session

Problem information

Author: InfBesos

Generation: 2026-01-25T16:54:26.417Z

© Jutge.org, 2006–2026.
https://jutge.org
