Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Sum Consecutives by StanislauL
def sum_consecutives(a):
res, curr = [], None
for x in a:
if x==curr: res[-1]+=x
else:
res.append(x)
curr = x
return res
Aug. 2, 2019