solved day 1
parent
d12c935f9d
commit
9bf6b898db
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,25 @@
|
|||
#!/bin/env ruby
|
||||
require 'pry'
|
||||
|
||||
elves = File.readlines('./input').map(&:strip)
|
||||
totals = []
|
||||
count = 0
|
||||
elves.each do |calories|
|
||||
if calories.empty?
|
||||
totals.push(count)
|
||||
count = 0
|
||||
else
|
||||
count += calories.to_i
|
||||
end
|
||||
end
|
||||
|
||||
puts "Part 1 Solution: #{totals.max}"
|
||||
|
||||
top_three = 0
|
||||
3.times do
|
||||
top_three += totals.delete(totals.max)
|
||||
end
|
||||
|
||||
puts "Part 2 SOlution: #{top_three}"
|
||||
|
||||
# binding.pry
|
Loading…
Reference in New Issue