Created
August 8, 2023 19:55
-
-
Save kolemannix/f11497c54ddba97a48b327928373775b to your computer and use it in GitHub Desktop.
Aoc_2022_day6_simple
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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