Skip to content

Commit d0ad64c

Browse files
committed
Use Int in gaussian elimination solution in 2025 day 10 part 2
1 parent 0fc9660 commit d0ad64c

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,13 @@ object Day10 {
117117
*/
118118

119119
override def fewestPresses(machine: Machine): Int = {
120-
val zeroCol = machine.joltages.map(_ => 0L)
120+
val zeroCol = machine.joltages.map(_ => 0)
121121
val rows =
122122
machine.buttons
123-
.map(_.foldLeft(zeroCol)(_.updated(_, 1L)))
123+
.map(_.foldLeft(zeroCol)(_.updated(_, 1)))
124124
.transpose
125125

126-
val sol = GaussianElimination.solve(rows, machine.joltages.map(_.toLong))
126+
val sol = GaussianElimination.solve(rows, machine.joltages)
127127
//val mSum = m.transpose.map(_.sum) // TODO: use?
128128

129129
def helper(freeMaxs: List[Int]): Iterator[List[Int]] = freeMaxs match { // TODO: this seems like it should exist from earlier somewhere
@@ -140,10 +140,10 @@ object Day10 {
140140
val dependentMaxs = sol.dependentVars.map(maxs)
141141
(for {
142142
freeVals <- helper(freeMaxs.toList)
143-
dependentVals = sol.evaluate(freeVals.map(_.toLong))
143+
dependentVals = sol.evaluate(freeVals)
144144
if dependentVals.forall(_ >= 0)
145145
if (dependentVals lazyZip dependentMaxs).forall(_ <= _)
146-
} yield dependentVals.sum.toInt + freeVals.sum).min
146+
} yield dependentVals.sum + freeVals.sum).min
147147
}
148148
}
149149

0 commit comments

Comments
 (0)