def sum_sections(secs, max_level)
     0.upto(max_level) do |cur_level|
       i = 0
       while i < secs.length
         if (secs[i][:level] == cur_level)
           (ctr,ni) = sum_lower_sections(secs, i+1,cur_level)
           secs[i][:swords] = ctr
           i = ni
         else
           i += 1
         end
       end
     end
     secs
   end
def sum_sections(secs, max_level)
     0.upto(max_level) do |cur_level|
       i = 0
       while i < secs.length
         if (secs[i][:level] == cur_level)
           (ctr,ni) = sum_lower_sections(secs, i+1,cur_level)
           secs[i][:swords] = ctr
           i = ni
         else
           i += 1
         end
       end
     end
     secs
   end
Sum the word counts of lower sections