Decrease runtime by increasing cache size.
All checks were successful
Solve / example-action (push) Successful in 3m16s

This commit is contained in:
Logiar 2024-12-11 19:42:02 +01:00
parent 5fd63ac62f
commit aef2dc6159
Signed by: Logiar
SSH Key Fingerprint: SHA256:tq77C31em1ZG4oELIHC3k62wq5UzPSXmhqH8g62whIY

View File

@ -26,7 +26,7 @@ class PriorityCache<K, V>(private val maxSize: Int) {
return cache.containsKey(key) return cache.containsKey(key)
} }
} }
val priorityCache = PriorityCache<String, Long>(20000) val priorityCache = PriorityCache<String, Long>(50000)
fun getStonesAfter(input: List<Long>,iterations: Int, cache: PriorityCache<String, Long>): Long { fun getStonesAfter(input: List<Long>,iterations: Int, cache: PriorityCache<String, Long>): Long {
var sum = 0L var sum = 0L
for (i in input) { for (i in input) {