aoc2022/01.rb
2022-11-30 23:59:44 -06:00

24 lines
294 B
Ruby

contents = File.open("01.txt").read
ans1 = contents
.split("\n\n")
.map do |s|
s.split("\n")
.map(&:to_i)
.sum
end
.max
puts ans1
ans2 = contents
.split("\n\n")
.map do |s|
s.split("\n")
.map(&:to_i)
.sum
end
.sort
.last(3)
.sum
puts ans2