day01: Only sort elves once
This commit is contained in:
parent
c1db9c86f1
commit
ea271f2e9a
1 changed files with 3 additions and 3 deletions
6
day01.rb
6
day01.rb
|
@ -1,5 +1,5 @@
|
||||||
input = STDIN.read.split "\n\n"
|
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 1: #{elves.last}"
|
||||||
puts "Part 2: #{elves.sort.last(3).sum}"
|
puts "Part 2: #{elves.last(3).sum}"
|
||||||
|
|
Loading…
Reference in a new issue