Use os-lib, Add command to run all problems
This commit is contained in:
@@ -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)
|
||||||
|
|||||||
@@ -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"
|
||||||
// )
|
)
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user