Skip to content

Commit 3d8162a

Browse files
committed
rx omg
1 parent faaa18d commit 3d8162a

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

docs/2023/puzzles/day20.md

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -261,20 +261,17 @@ def part1(input: String): Long =
261261
## Part 2
262262

263263
Part 2 asks how many button presses are required for a particular output
264-
module "rv" to receive a high pulse.
264+
module "rx" to receive a high pulse.
265265

266266
This can crudely be solved by just running the Elves' state machine
267267
until you find such a pulse:
268268

269269
```scala
270270
Iterator
271271
.iterate(MachineFSM(machine))(_.nextState)
272-
.find: state =>
273-
state.queue.headOption match
274-
case Some(Pulse(_, "rv", true)) => true
275-
case _ => false
276-
.get
277-
.presses
272+
.findMap: state =>
273+
state.queue.headOption.collect:
274+
case Pulse(_, "rx", false) => state.presses
278275
```
279276

280277
Knowing the Advent of Code, this will not complete in any reasonable
@@ -285,7 +282,7 @@ The state machine also does not obviously lend itself to a mathematical
285282
reduction, at least not within the available time constraints.
286283

287284
Instead, we have to look at the actual input text itself. Analyzing the
288-
structure of the machine, it turns out that the "rv" module is fed by a
285+
structure of the machine, it turns out that the "rx" module is fed by a
289286
conjunction module which is itself fed by four completely independent
290287
subgraphs. This terminal conjunction will emit a high pulse when it
291288
receives a high pulse from each of the subgraphs.
@@ -332,10 +329,10 @@ object Problem2FSM:
332329
#### Subgraphs
333330

334331
The terminal module is a module that doesn't serve as an input to
335-
any other module. We could hardcode "rv", but this is more general.
332+
any other module. We could hardcode "rx", but this is more general.
336333
The output modules of the independent subgraphs are then all the
337334
inputs to the sole input to this terminal conjunction:
338-
("a", "b", "c", "d") -> "penultimate" -> "rv".
335+
("a", "b", "c", "d") -> "penultimate" -> "rx".
339336

340337
```scala
341338
private def subgraphs(machine: Machine): Set[ModuleName] =

0 commit comments

Comments
 (0)