File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed
main/scala/eu/sim642/adventofcode2025
test/scala/eu/sim642/adventofcode2025 Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change 11package eu .sim642 .adventofcode2025
22
3- import eu .sim642 .adventofcode2016 .Day20 .Interval
3+ import eu .sim642 .adventofcode2016 .Day20 .{ Interval , mergeIntervals }
44
55object Day5 {
66
@@ -11,6 +11,10 @@ object Day5 {
1111 available.count(id => fresh.exists(_.contains(id)))
1212 }
1313
14+ def countFresh (database : Database ): Long = {
15+ mergeIntervals(database.fresh).map(_.size).sum
16+ }
17+
1418 def parseInterval (s : String ): Interval = s match {
1519 case s " $i- $j" => Interval (i.toLong, j.toLong)
1620 }
@@ -26,5 +30,6 @@ object Day5 {
2630
2731 def main (args : Array [String ]): Unit = {
2832 println(countFreshAvailable(parseDatabase(input)))
33+ println(countFresh(parseDatabase(input)))
2934 }
3035}
Original file line number Diff line number Diff line change @@ -25,4 +25,12 @@ class Day5Test extends AnyFunSuite {
2525 test(" Part 1 input answer" ) {
2626 assert(countFreshAvailable(parseDatabase(input)) == 679 )
2727 }
28+
29+ test(" Part 2 examples" ) {
30+ assert(countFresh(parseDatabase(exampleInput)) == 14 )
31+ }
32+
33+ test(" Part 2 input answer" ) {
34+ assert(countFresh(parseDatabase(input)) == 358155203664116L )
35+ }
2836}
You can’t perform that action at this time.
0 commit comments