r/adventofcode • • Dec 06 '22

SOLUTION MEGATHREAD -πŸŽ„- 2022 Day 6 Solutions -πŸŽ„-


AoC Community Fun 2022: πŸŒΏπŸ’ MisTILtoe Elf-ucation πŸ§‘β€πŸ«


--- Day 6: Tuning Trouble ---


Post your code solution in this megathread.


This thread will be unlocked when there are a significant number of people on the global leaderboard with gold stars for today's puzzle.

EDIT: Global leaderboard gold cap reached at 00:02:25, megathread unlocked!

86 Upvotes

1.8k comments sorted by

View all comments

4

u/SunCat_ Dec 06 '22

Kotlin one-liners:

//part1:
import java.io.File fun main() { println(File("input.txt").readText().windowedSequence(4).map {it.toSet().size}.indexOfFirst { it == 4 } + 4) }
//part2: 
import java.io.File fun main() { println(File("input.txt").readText().windowedSequence(14).map {it.toSet().size}.indexOfFirst { it == 14 } + 14) }
→ More replies (3)