day 1
This commit is contained in:
commit
663fb5d574
2 changed files with 2291 additions and 0 deletions
24
01.rb
Normal file
24
01.rb
Normal file
|
@ -0,0 +1,24 @@
|
|||
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
|
||||
|
Loading…
Reference in a new issue