La mia en Maple y Excel:
F:=cat(currentdir(),"\\Template 1.txt"):
Calorias:=proc(File,n)
local S, S_cont, r1, r2, S_aux, i, j;
S:=[seq(0,i=1..n)];
S_aux:=S;
S_cont:=0;
r1:=FileTools[Text][ReadLine](File);
r2:=FileTools[Text][ReadLine](File);
while r1 <> NULL or r2 <> NULL do
if r1="" or (r1 <> NULL and r2 = NULL) then
for i from 1 to n do
if S_cont>S[i] then
S[i]:=S_cont;
for j from i+1 to n do
S[j]:=S_aux[j-1];
od;
break;
fi;
od;
S_cont:=0;
S_aux:=S;
else
S_cont:=S_cont+parse(r1);
fi;
r1:=r2;
r2:=FileTools[Text][ReadLine](File);
od;
FileTools[Text][Close](File);
RETURN(S);
end:
add(x, x in Calorias(F,1));
add(x, x in Calorias(F,3));
Un saludo