2022/01/script.rb

28 lines
438 B
Ruby
Raw Permalink Normal View History

2022-12-01 12:03:16 +01:00
#!/usr/bin/env ruby
require_relative '../common'
class Day01 < Day
def part1
input.each_with_object([0]) do |row, result|
if row == ""
result << 0
else
result[-1] += row.to_i
end
end.max
end
def part2
input.each_with_object([0]) do |row, result|
if row == ""
result << 0
else
result[-1] += row.to_i
end
end.sort[-3..-1].sum
end
end
Day01.run