Resolve day 1

main
Guillaume Dott 2022-12-01 12:03:16 +01:00
parent 4f14f9b5af
commit b5d8831fe8
2 changed files with 2282 additions and 0 deletions

2255
01/input 100644

File diff suppressed because it is too large Load Diff

27
01/script.rb 100755
View File

@ -0,0 +1,27 @@
#!/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