aboutsummaryrefslogtreecommitdiff
path: root/day01/part2.rb
blob: c7bf668efdba0810cf802be747a04e6a57ecbf28 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
items = $stdin.readlines.map(&:strip)
elves = []

sum = 0
items.each do |item|
  if item.empty?
    elves << sum
    sum = 0
  else
    sum += item.to_i
  end
end
elves << sum

puts elves.max(3).sum