Skip to content

Instantly share code, notes, and snippets.

@cyberzac
Created December 6, 2022 15:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cyberzac/88755bc346ce228f181b170d00342aa6 to your computer and use it in GitHub Desktop.
Save cyberzac/88755bc346ce228f181b170d00342aa6 to your computer and use it in GitHub Desktop.
AdventOfCode 2022
object Day6 extends Day :
def part1(input: Iterator[String]) =
markerFinder(input, 4)
private def markerFinder(input: Iterator[String], length: Int): String = {
input.map(_
.sliding(length)
.map(_.toSet.size)
.zipWithIndex
.collectFirst {
case (`length`, i) => i + length
}.get
).mkString(" ")
}
def part2(input: Iterator[String]) =
markerFinder(input, 14)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment