Day 22 part 1

This commit is contained in:
Sven Weidauer 2025-01-04 18:04:50 +01:00
parent 89445f1df9
commit 04350e219a
2 changed files with 2173 additions and 0 deletions

View file

@ -0,0 +1,17 @@
fun main() {
val part1 = readInput("day22.txt")
.map { it.toLong() }
.map { randomSequence(it).elementAt(2000) }
.sum()
println("Part 1: $part1")
}
fun prune(x: Long) = x % 16777216
fun mix(a: Long, b: Long) = a xor b
fun randomSequence(start: Long) = generateSequence(start) { current ->
val a = prune(mix(current, current * 64))
val b = prune(mix(a, a / 32))
prune(mix(b, b * 2048))
}

File diff suppressed because it is too large Load diff