Created
December 6, 2022 08:28
-
-
Save txdv/0f9d889d30da12a1494cb3e91d2c180d to your computer and use it in GitHub Desktop.
aoc 2022 puzzle06
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
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