aoc2022/01.rb

25 lines
294 B
Ruby
Raw Normal View History

2022-12-01 05:59:44 +00:00
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