AoC2022/day01/solution.rb

26 lines
390 B
Ruby

#!/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