aoc
/
2022
1
0
Fork 0

day01: Only sort elves once

This commit is contained in:
Sijmen 2022-12-01 15:53:39 +01:00
parent c1db9c86f1
commit ea271f2e9a
Signed by: vijfhoek
GPG Key ID: DAF7821E067D9C48
1 changed files with 3 additions and 3 deletions

View File

@ -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}"