Skip to content

Commit

Permalink
2024 - Day 11 - reformatted.
Browse files Browse the repository at this point in the history
  • Loading branch information
fmmr committed Dec 11, 2024
1 parent 68d6f71 commit e82eaea
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions src/main/kotlin/no/rodland/advent_2024/Day11.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ class Day11(val input: List<String>) : Day<Long, Long, List<Long>> {

private fun Long.numberStones(i: Int, memoization: MutableMap<Pair<Long, Int>, Long>): Long {
if (i == 0) return 1
if (memoization.containsKey(this to i)) {
return memoization[this to i]!!
}
memoization[this to i]?.let { return it }
return this.runRules().sumOf { it.numberStones(i - 1, memoization) }.also { memoization[this to i] = it }
}

Expand Down Expand Up @@ -57,8 +55,4 @@ class Day11(val input: List<String>) : Day<Long, Long, List<Long>> {
}

override val day = "11".toInt()
}




}

0 comments on commit e82eaea

Please sign in to comment.