diff options
Diffstat (limited to 'day01/part2.rb')
-rw-r--r-- | day01/part2.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/day01/part2.rb b/day01/part2.rb new file mode 100644 index 0000000..c7bf668 --- /dev/null +++ b/day01/part2.rb @@ -0,0 +1,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 |