Joris PZ
12/07/2019, 11:14 AMReceiveChannel<Int>
, its output a SendChannel<Int>
s, and the channels are wired such that machine A's output channel is the input for machine B. Machine E's output is wired to both machine A's input as well as a separate output channel using a BroadcastChannel<Int>
.
Then it's just a matter of sending the input phases and the initial 0
to A, and off we go - no manual state management needed, and the data just flows between the coroutines. I'm very pleased I got this working, required a lot of tinkering and refactoring.
My coroutine computer is <https://github.com/jorispz/aoc-2019/blob/master/src/commonMain/kotlin/day07/CoComputer.kt>, the solution iterating over the phases and setting up the channels is in <https://github.com/jorispz/aoc-2019/blob/master/src/commonMain/kotlin/day07/p07.kt>marstran
12/07/2019, 11:16 AMJoris PZ
12/07/2019, 11:25 AMkarelpeeters
12/07/2019, 2:53 PM