From e00e002cd635f81e9ed6466b1084ce8e7eb76797 Mon Sep 17 00:00:00 2001 From: chrisly42 Date: Mon, 23 Dec 2024 16:31:11 +0100 Subject: [PATCH] Bitset is even faster (<1 sec). --- src/aoc2024/Day22.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/aoc2024/Day22.kt b/src/aoc2024/Day22.kt index 7ef9cd2..ac43a31 100644 --- a/src/aoc2024/Day22.kt +++ b/src/aoc2024/Day22.kt @@ -6,6 +6,7 @@ import kotlinx.coroutines.awaitAll import kotlinx.coroutines.runBlocking import println import readInput +import java.util.* /* --- Day 22: Monkey Market --- @@ -76,7 +77,7 @@ fun main() { var lastd = 0 var code = 0 var countDown = 4 - val seenArray = BooleanArray(19 * 19 * 19 * 19) + val seenArray = BitSet(19 * 19 * 19 * 19) for (v in priceSequence(it).take(2001)) { val d = v % 10 val delta = d - lastd