Day 6: Turing Trouble
Puzzle Description
Scala Center Link
Scala Center Advent of Code 2022, Day 6
Full Solution Source
This one seems like it was easy to make short, even dumb stupid 2022 me got a short answer:
def process(input: String, size: Int): Int =
input.sliding(size).indexWhere: it =>
it.combinations(2).forall(i => i.charAt(0) != i.charAt(1))
+ size
Benchmark
Part 1
|
Mean |
Error |
|
|---|---|---|
|
JVM |
1.549 ms |
+/- 0.020 ms |
|
JS |
2.832 ms |
+/- 0.003 ms |
|
Native |
2.391 ms |
+/- 0.002 ms |
Part 2
|
Mean |
Error |
|
|---|---|---|
|
JVM |
5.029 ms |
+/- 0.235 ms |
|
JS |
12.358 ms |
+/- 0.017 ms |
|
Native |
12.251 ms |
+/- 0.021 ms |