AoC2022/day01/solution.rb

26 lines
390 B
Ruby
Raw Normal View History

2022-12-02 16:31:44 +00:00
#!/bin/env ruby
require 'pry'
elves = File.readlines('./input').map(&:strip)
totals = []
count = 0
elves.each do |calories|
if calories.empty?
totals.push(count)
count = 0
else
count += calories.to_i
end
end
puts "Part 1 Solution: #{totals.max}"
top_three = 0
3.times do
top_three += totals.delete(totals.max)
end
puts "Part 2 SOlution: #{top_three}"
# binding.pry