Skip to content

Commit c56403a

Browse files
committed
Refactor 2025 day 1 part 2
1 parent 89824ad commit c56403a

File tree

1 file changed

+3
-7
lines changed
  • src/main/scala/eu/sim642/adventofcode2025

1 file changed

+3
-7
lines changed

src/main/scala/eu/sim642/adventofcode2025/Day1.scala

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,9 @@ object Day1 {
1818

1919
object Part2 extends Part {
2020
override def password(rotations: Seq[Int]): Int = {
21-
rotations
22-
.flatMap({ // expand all rotations to single to make each tick observable, this is silly but works
23-
case i if i >= 0 => Seq.fill(i)(1)
24-
case i if i < 0 => Seq.fill(-i)(-1)
25-
})
26-
.scanLeft[Int](50)((a, b) => (a + b) %+ 100) // TODO: why can't use implicit arguments?
27-
.count(_ == 0)
21+
// expand all rotations to single to make each click observable, this is silly but works
22+
val newRotations = rotations.flatMap(i => Seq.fill(i.abs)(i.sign))
23+
Part1.password(newRotations)
2824
}
2925
}
3026

0 commit comments

Comments
 (0)