Skip to content

Commit b43c00e

Browse files
committed
2024 - Day 24 - finally tracked down bug in cache.
1 parent d2cb625 commit b43c00e

File tree

1 file changed

+3
-3
lines changed
  • src/main/kotlin/no/rodland/advent_2024

1 file changed

+3
-3
lines changed

src/main/kotlin/no/rodland/advent_2024/Day24.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ class Day24(val input: List<String>) : Day<Long, Long, Pair<Map<String, Day24.Wi
1313
val (values, logic) = parsed
1414
val system = values.toMutableMap()
1515

16-
val map = logic
17-
.map { (k, v) -> buildNode(system, logic, k, v) }
16+
val map = logic.map { (k, v) -> buildNode(system, logic, k, v) }
1817
println("hm - ran through buildNode: $i")
1918
return map
2019
.filter { it.name.startsWith("z") }
@@ -30,13 +29,14 @@ class Day24(val input: List<String>) : Day<Long, Long, Pair<Map<String, Day24.Wi
3029
i++
3130
val (aKey, op, bKey) = v.split(" ")
3231
val a = system[aKey] ?: buildNode(system, input, aKey, input[aKey]!!)
33-
val b = system[bKey] ?: buildNode(system, input, aKey, input[bKey]!!)
32+
val b = system[bKey] ?: buildNode(system, input, bKey, input[bKey]!!)
3433
val wire = when (op) {
3534
"AND" -> Wire(k, AND(a, b))
3635
"OR" -> Wire(k, OR(a, b))
3736
"XOR" -> Wire(k, XOR(a, b))
3837
else -> error("Unknown op $op")
3938
}
39+
system[k] = wire
4040
return wire
4141
}
4242

0 commit comments

Comments
 (0)