15 lines
323 B
Text
15 lines
323 B
Text
function equilibrium(sequence s)
|
|
atom lower_sum = 0
|
|
atom higher_sum = sum(s)
|
|
sequence res = {}
|
|
for i=1 to length(s) do
|
|
higher_sum -= s[i]
|
|
if lower_sum=higher_sum then
|
|
res &= i
|
|
end if
|
|
lower_sum += s[i]
|
|
end for
|
|
return res
|
|
end function
|
|
|
|
? equilibrium({-7,1,5,2,-4,3,0})
|