day01: Only sort elves once
This commit is contained in:
parent
c1db9c86f1
commit
ea271f2e9a
6
day01.rb
6
day01.rb
|
@ -1,5 +1,5 @@
|
|||
input = STDIN.read.split "\n\n"
|
||||
elves = input.map { |elf| elf.split("\n").map(&:to_i).sum }
|
||||
elves = input.map { |elf| elf.split("\n").map(&:to_i).sum }.sort
|
||||
|
||||
puts "Part 1: #{elves.max}"
|
||||
puts "Part 2: #{elves.sort.last(3).sum}"
|
||||
puts "Part 1: #{elves.last}"
|
||||
puts "Part 2: #{elves.last(3).sum}"
|
||||
|
|
Loading…
Reference in New Issue