Commit a9375c1b authored by Alexander Gehrke's avatar Alexander Gehrke
Browse files

Use inputs lib from 2015 solution

parent b92048c8
......@@ -5,7 +5,19 @@ case class Location(inputDir: String, day: Int)
def inputLines(using l: Location) = scala.io.Source.fromFile(s"${l.inputDir}/day${l.day}.txt").getLines
def simpleInput(solver: String => String)(using l: Location): String =
solver(inputLines.mkString)
def input[A](format: String => A = identity)(solver: List[A] => String)(using l: Location): String =
solver(inputLines.map(format).toList)
inputF(format)(List)(solver)
def inputF[A, C[_]](format: String => A = identity)(coll: collection.Factory[A, C[A]])(solver: C[A] => String)(using l: Location): String =
solver(inputLines.map(format).to(coll))
def flatInput[A](format: String => List[A] = List.apply)(solver: List[A] => String)(using l: Location): String =
flatInputF(format)(List)(solver)
def flatInputF[A, C[_]](format: String => IterableOnce[A] = identity)(coll: collection.Factory[A, C[A]])(solver: C[A] => String)(using l: Location): String =
solver(inputLines.flatMap(format).to(coll))
def boolChar(trueChar: Char): String => Vector[Boolean] = _.map(_ == trueChar).toVector
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment