advent-of-code/2019/Scala/day07/Day07.scala

22 lines
516 B
Scala
Raw Normal View History

2019-12-07 18:49:02 +01:00
package day07
import day07.intcode.Solver
class Day07(original: Array[Int])
{
val phases: List[Array[Int]] = Array(0, 1, 2, 3, 4).permutations.toList
2019-12-07 19:39:28 +01:00
def solveP1(): Int =
2019-12-07 18:49:02 +01:00
{
val solver = new Solver(original)
2019-12-07 19:39:28 +01:00
phases.map(seq => solver.solveSequenceSingleRun(seq)).max
2019-12-07 18:49:02 +01:00
}
val phases2: List[Array[Int]] = Array(5, 6, 7, 8, 9).permutations.toList
2019-12-07 19:39:28 +01:00
def solveP2(): Int =
2019-12-07 18:49:02 +01:00
{
val solver = new Solver(original)
2019-12-07 19:39:28 +01:00
phases2.map(seq => solver.solveSequenceMultiRun(seq)).max
2019-12-07 18:49:02 +01:00
}
}