Skip to content

Instantly share code, notes, and snippets.

@txdv
Created December 6, 2022 08:28
Show Gist options
  • Save txdv/0f9d889d30da12a1494cb3e91d2c180d to your computer and use it in GitHub Desktop.
Save txdv/0f9d889d30da12a1494cb3e91d2c180d to your computer and use it in GitHub Desktop.
aoc 2022 puzzle06
import Converters._
object Puzzle06 extends Runnable {
def find(line: String, count: Int): Int = {
val result = line.sliding(count).zipWithIndex.find { case (e, i) =>
e.toSet.size == count
} getOrElse {
???
}
count + result._2
}
def first(input: Seq[String]): String = {
find(input.head, 4)
}
def second(input: Seq[String]): String = {
find(input.head, 14)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment