Skip to content

Instantly share code, notes, and snippets.

@kolemannix
Created August 8, 2023 19:55
Show Gist options
  • Save kolemannix/f11497c54ddba97a48b327928373775b to your computer and use it in GitHub Desktop.
Save kolemannix/f11497c54ddba97a48b327928373775b to your computer and use it in GitHub Desktop.
Aoc_2022_day6_simple
def func(s: String, n: Int) = {
val index = (0 until s.length).find { i =>
s.slice(i, i + n).distinct.length == n
}
index.map(_ + n)
}
def part1(s: String): Option[Int] = func(s, 4)
def part2(s: String): Option[Int] = func(s, 14)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment