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

22 lines
586 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
def solveP1(): (Int, List[Int]) =
{
val solver = new Solver(original)
phases.map(seq => (solver.solveSequenceSingleRun(seq), seq.toList)).maxBy(_._1)
}
val phases2: List[Array[Int]] = Array(5, 6, 7, 8, 9).permutations.toList
def solveP2(): (Int, List[Int]) =
{
val solver = new Solver(original)
phases2.map(seq => (solver.solveSequenceMultiRun(seq), seq.toList)).maxBy(_._1)
}
}