Compare commits

...

2 Commits

Author SHA1 Message Date
Christian
a7ee9bd981 Add nativeImage build config 2024-12-08 10:30:53 +01:00
Christian
1d14e2f2b5 Minor cleanup 2024-12-08 10:30:53 +01:00
2 changed files with 19 additions and 7 deletions

View File

@@ -4,10 +4,9 @@ import dev.ctsk.aoc._
import dev.ctsk.aoc.Direction._ import dev.ctsk.aoc.Direction._
import scala.annotation.tailrec import scala.annotation.tailrec
import scala.collection.mutable import scala.collection.mutable
import scala.collection.parallel.CollectionConverters._
object Day06 extends Solver(6): object Day06 extends Solver(6):
def analyse(grid: Grid[Char]): Array[Array[Array[Int]]] = private def analyse(grid: Grid[Char]): Array[Array[Array[Int]]] =
val skipMap = Array.fill(grid.height, grid.width, 4)(-1) val skipMap = Array.fill(grid.height, grid.width, 4)(-1)
for for
obstacle <- grid.find(_ == '#') obstacle <- grid.find(_ == '#')
@@ -43,9 +42,7 @@ object Day06 extends Solver(6):
val next = cur.step val next = cur.step
grid(next.pos) match grid(next.pos) match
case Some('#') => case Some('#') =>
if seen.contains(cur) then return true if seen.add(cur) then rec(cur.turnRight) else true
seen += cur
rec(cur.turnRight)
case Some(_) => case Some(_) =>
if next.pos == obstacle then return rec(cur.turnRight) if next.pos == obstacle then return rec(cur.turnRight)
if next.pos.x == obstacle.x || next.pos.y == obstacle.y if next.pos.x == obstacle.x || next.pos.y == obstacle.y

View File

@@ -2,10 +2,25 @@ package build
import mill._, scalalib._ import mill._, scalalib._
object aoc extends ScalaModule { import $ivy.`io.github.alexarchambault.mill::mill-native-image::0.1.29`
import io.github.alexarchambault.millnativeimage.NativeImage
object aoc extends ScalaModule with NativeImage {
def scalaVersion = "3.5.2" def scalaVersion = "3.5.2"
def ivyDeps = Agg( def ivyDeps = Agg(
ivy"com.lihaoyi::os-lib:0.11.3", ivy"com.lihaoyi::os-lib:0.11.3",
ivy"org.scala-lang.modules::scala-parallel-collections:1.0.4" ivy"org.scala-lang.modules::scala-parallel-collections:1.0.4"
) )
}
def nativeImageName = "aoc"
def nativeImageMainClass = "dev.ctsk.aoc.main"
def nativeImageClassPath = runClasspath()
def nativeImageGraalVmJvmId = "graalvm-java23"
def nativeImageOptions = Seq(
"--initialize-at-build-time",
"--no-fallback",
"--enable-url-protocols=http,https",
"-Djdk.http.auth.tunneling.disabledSchemes=",
)
}