@@ -13,8 +13,7 @@ class Day24(val input: List<String>) : Day<Long, Long, Pair<Map<String, Day24.Wi
13
13
val (values, logic) = parsed
14
14
val system = values.toMutableMap()
15
15
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) }
18
17
println (" hm - ran through buildNode: $i " )
19
18
return map
20
19
.filter { it.name.startsWith(" z" ) }
@@ -30,13 +29,14 @@ class Day24(val input: List<String>) : Day<Long, Long, Pair<Map<String, Day24.Wi
30
29
i++
31
30
val (aKey, op, bKey) = v.split(" " )
32
31
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]!! )
34
33
val wire = when (op) {
35
34
" AND" -> Wire (k, AND (a, b))
36
35
" OR" -> Wire (k, OR (a, b))
37
36
" XOR" -> Wire (k, XOR (a, b))
38
37
else -> error(" Unknown op $op " )
39
38
}
39
+ system[k] = wire
40
40
return wire
41
41
}
42
42
0 commit comments