Use os-lib, Add command to run all problems

This commit is contained in:
Christian
2024-12-05 16:09:58 +01:00
parent 94eb34f386
commit 4445e63329
2 changed files with 25 additions and 17 deletions

View File

@@ -10,10 +10,8 @@ val solvers = Map[Int, Solver](
5 -> Day05 5 -> Day05
) )
@main def main(day: String, input: String): Unit = def runSolver(solver: Solver, input: os.Path): Unit =
solvers.get(day.toInt) match val (timings, solution) = solver.run(input)
case Some(solver) =>
val (timings, solution) = solver.run(os.pwd / input)
sys.env.get("AOC_BENCH") match sys.env.get("AOC_BENCH") match
case Some(_) => case Some(_) =>
println(solution.p1) println(solution.p1)
@@ -23,5 +21,15 @@ val solvers = Map[Int, Solver](
println(f"Part 1: ${solution.p1}%15s ${timings.p1}%15s μs") println(f"Part 1: ${solution.p1}%15s ${timings.p1}%15s μs")
println(f"Part 2: ${solution.p2}%15s ${timings.p2}%15s μs") println(f"Part 2: ${solution.p2}%15s ${timings.p2}%15s μs")
case None => @main def main(day: String, input: String): Unit =
println(s"Day $day not solved") val num = """(\d+)""".r
day match
case "all" =>
solvers.foreach { case (day, solver) =>
runSolver(solver, os.pwd / os.RelPath(input) / f"$day%02d.in")
}
case num(_) =>
solvers.get(day.toInt) match
case Some(solver) => runSolver(solver, os.pwd / os.RelPath(input))
case None => println(s"Day $day not solved")
case _ => println(day)

View File

@@ -4,7 +4,7 @@ import mill._, scalalib._
object aoc extends ScalaModule { object aoc extends ScalaModule {
def scalaVersion = "3.5.2" def scalaVersion = "3.5.2"
// def ivyDeps = Agg( def ivyDeps = Agg(
// ivy"org.scala-lang.modules::scala-parallel-collections:1.0.4" ivy"com.lihaoyi::os-lib:0.11.3"
// ) )
} }