AdventOfCode/2022/day1-v2.scala

12 lines
469 B
Scala
Raw Permalink Normal View History

2022-12-01 21:38:31 +10:30
import scala.collection.mutable.ArrayBuffer
import scala.io.Source
@main def main() =
2022-12-03 17:22:53 +10:30
val elfRations = Source.fromFile("input/1").mkString.split("\n\n").map(_.split("\n").map(_.toInt))
2022-12-01 21:38:31 +10:30
val sortedElfCalories = elfRations.map(_.sum).sorted
// Part 1 solution: Total calories held by elf with the most total calories
println(s"${sortedElfCalories.last}")
// Part 2 solution: Total calories held by the top 3 elves
println(s"${sortedElfCalories.takeRight(3).sum}")